* d/rules: Defang dh_auto_test when built with nocheck
* Stop using Priority: extra
* d/tests/build: Update for GTK+ 4.0
+ * d/missing-sources: Remove, no longer needed
-- Jeremy Bicha <jbicha@debian.org> Fri, 19 Jan 2018 22:05:35 -0500
Copyright (C) 2000 Red Hat, Inc.
License: LGPL-2+ or sun-permissive
-Files:
- debian/missing-sources/zlib.js-0.1.6
- gdk/broadway/rawinflate.min.js
-Copyright:
- © 2012 imaya
-License: Expat
-
Files:
gtk/inspector/logs.*
Copyright:
+++ /dev/null
-Missing sources from gtk+3.0
-============================
-
-zlib.js-0.1.6
--------------
-
-Source for: gdk/broadway/rawinflate.min.js
-Obtained from: <https://github.com/imaya/zlib.js> tag "0.1.6"
-Files removed:
- bin/* except for rawinflate.min.js* (precompiled, not needed here)
- .travis/, .travis.yml (regression tests, not needed here)
- test/ (regression tests, not needed here)
- vendor/google-closure-compiler/ (third-party, source not included)
- vendor/mt.js/ (third-party, only needed for tests)
-
-gdk/broadway/rawinflate.min.js is identical to bin/rawinflate.min.js.
-
-Debian's closure-compiler_20130227+dfsg1-6 is not identical to the one
-originally distributed with zlib.js, but produces output closely resembling
-bin/rawinflate.min.js when invoked like this (command line adapted from
-build.xml, using bin/rawinflate.min.js.map to determine minimal sources):
-
- cat LICENSE_min
- echo -n '(function() {'
- closure-compiler --compilation_level=ADVANCED_OPTIMIZATIONS \
- --warning_level=VERBOSE \
- --define=goog.DEBUG=false \
- --summary_detail_level=3 \
- --language_in=ECMASCRIPT5_STRICT \
- --source_map_format=V3 \
- --process_closure_primitives \
- --js closure-primitives/base.js \
- --js define/typedarray/hybrid.js \
- --js=src/export_object.js \
- --js=src/huffman.js \
- --js=src/rawinflate.js \
- --js=src/zlib.js \
- --js=export/rawinflate.js
- echo -n '}).call(this); //@ sourceMappingURL=rawinflate.min.js.map'
+++ /dev/null
-zlib.js-0.1.6/src/rawinflate.js
\ No newline at end of file
+++ /dev/null
-
-# Change Log
-
-
-## 0.1.6: 2013/05/10
-
-https://github.com/imaya/zlib.js/compare/0.1.5...0.1.6
-
-
-### compression
-
-- export raw deflate
-
-
-### decompression
-
-- export raw inflate
-- fix inflate stream exporting
-
-
-### etc
-
-- export crc-32
-- add pretty print build
-- optimize compile settings
-- add english document
-- support source maps
-- support Travis CI
-- refactor unit test
-- update closure compiler (custom version)
-
-
--------------------------------------------------------------------------------
-
-
-## 0.1.5: 2013/02/10
-
-https://github.com/imaya/zlib.js/compare/0.1.4...0.1.5
-
-
-### compression
-
-- fix PKZIP CRC-32 bug
-
-
-### etc
-
-- update PKZIP unit test
-
-
--------------------------------------------------------------------------------
-
-
-## 0.1.4: 2013/02/10
-
-https://github.com/imaya/zlib.js/compare/0.1.3...0.1.4
-
-
-### compression
-
-- add PKZIP compression (basic support)
-
-
-### decompression
-
-- add PKZIP decompression (basic support)
-
-
-### etc
-
-- refactor build environment (use export js file)
-- remove license comment in source code
-
-
--------------------------------------------------------------------------------
-
-
-## 0.1.3: 2012/12/21
-
-https://github.com/imaya/zlib.js/compare/0.1.2...0.1.3
-
-
-### compression
-
-- fix rare case bug
-
-
--------------------------------------------------------------------------------
-
-
-## 0.1.2: 2012/12/17
-
-https://github.com/imaya/zlib.js/compare/0.1.1...0.1.2
-
-
-### compression
-
-- fix adler-32 bug (byte order)
-- refactor raw deflate code
-
-### decompression
-
-- refactor inflate stream code
-
-### etc
-
-- update closure compiler (custom version)
-- update inflate unit test (enable adler-32 verification)
-
-
--------------------------------------------------------------------------------
-
-
-## 0.1.1: 2012/11/15
-
-https://github.com/imaya/zlib.js/compare/0.1.0...0.1.1
-
-
-### compression
-
-- fix huffman coding (add reverse package merge algorithm)
-
-### etc
-
-- fix gunzip unit test
-
-
--------------------------------------------------------------------------------
-
-
-## 0.1.0: 2012/09/24
-
-- first release
\ No newline at end of file
+++ /dev/null
-/**
- * @license
- * zlib.js
- * JavaScript Zlib Library
- * https://github.com/imaya/zlib.js
- *
- * The MIT License
- *
- * Copyright (c) 2012 imaya
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
+++ /dev/null
-/** @license zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */
\ No newline at end of file
+++ /dev/null
-zlib.js
-=======
-
-[](https://travis-ci.org/imaya/zlib.js)
-
-[Japanese version](./README.md)
-
-zlib.js is ZLIB(RFC1950), DEFLATE(RFC1951), GZIP(RFC1952) and PKZIP implementation in JavaScript.
-
-
-Usage
-------
-
-Use one in "bin" directory.
-
-- zlib_and_gzip.min.js: ZLIB + GZIP
- + (Raw)
- * rawdeflate.js: Raw Deflate
- * rawinflate.js: Raw Inflate
- + zlib.min.js: ZLIB Inflate + Deflate
- * inflate.min.js: ZLIB Inflate
- * deflate.min.js: ZLIB Deflate
- * inflate_stream.min.js: ZLIB Inflate (stream mode)
- + (GZIP)
- * gzip.min.js: GZIP
- * gunzip.min.js: GUNZIP
- + (PKZIP)
- * zip.min.js ZIP
- * unzip.min.js UNZIP
-- node-zlib.js: (ZLIB + GZIP for node.js)
-
-
-### Compression
-
-#### Raw Deflate
-
-```js
-// plain = Array.<number> or Uint8Array
-var defalte = new Zlib.RawDeflate(plain);
-var compressed = deflate.compress();
-```
-
-#### Raw Deflate Option
-
-See ZLIB Option.
-
-#### ZLIB
-
-```js
-// plain = Array.<number> or Uint8Array
-var defalte = new Zlib.Deflate(plain);
-var compressed = deflate.compress();
-```
-
-##### ZLIB Option
-
-Second argument of Zlib.Deflate constructor
-
-```js
-{
- compressionType: Zlib.Deflate.CompressionType, // compression type
- lazy: number // lazy matching parameter
-}
-```
-
-<code>Zlib.Deflate.CompressionType</code> is enumerable,
-Choose one in <code>NONE</code> (Store), <code>FIXED</code> (Fixed Huffman Coding), <code>DYNAMIC</code> (Dynamic Huffman Coding).
-Default value is <code>DYNAMIC</code>.
-
-<code>lazy</code> is Lazy Matching length.
-This parameter is deprecated.
-
-
-#### GZIP
-
-GZIP implementation is imcompleted.
-However no problem in usual use.
-
-```js
-// plain = Array.<number> or Uint8Array
-var gzip = new Zlib.Gzip(plain);
-var compressed = gzip.compress();
-```
-
-
-##### GZIP Option
-
-```js
-{
- deflateOptions: Object, // see: deflate option (ZLIB Option)
- flags: {
- fname: boolean, // use filename?
- comment: boolean, // use comment?
- fhcrc: boolean // use file checksum?
- },
- filename: string, // filename
- comment: string // comment
-}
-```
-
-
-#### PKZIP
-
-```js
-var zip = new Zlib.Zip();
-// plainData1
-zip.addFile(plainData1, {
- filename: stringToByteArray('foo.txt')
-});
-zip.addFile(plainData2, {
- filename: stringToByteArray('bar.txt')
-});
-zip.addFile(plainData3, {
- filename: stringToByteArray('baz.txt')
-});
-var compressed = zip.compress();
-
-function stringToByteArray(str) {
- var array = new (window.Uint8Array !== void 0 ? Uint8Array : Array)(str.length);
- var i;
- var il;
-
- for (i = 0, il = str.length; i < il; ++i) {
- array[i] = str.charCodeAt(i) & 0xff;
- }
-
- return array;
-}
-```
-
-##### PKZIP Option
-
-filename, comment, extraField are must use Uint8Array if enabled Typed Array.
-
-```js
-{
- filename: (Array.<number>|Uint8Array), // filename
- comment: (Array.<number>|Uint8Array), //comment
- extraField: (Array.<number>|Uint8Array), // extra field
- compress: boolean, // compress when called "addFile" method.
- compressionMethod: Zlib.Zip.CompressionMethod, // STORE or DEFLATE
- os: Zlib.Zip.OperatingSystem, // MSDOS or UNIX or MACINTOSH
- deflateOption: Object // see: ZLIB Option
-}
-```
-
-### Decompression
-
-#### Raw Deflate
-
-```js
-// compressed = Array.<number> or Uint8Array
-var inflate = new Zlib.RawInflate(compressed);
-var plain = inflate.decompress();
-```
-
-#### Raw Deflate Option
-
-See ZLIB Option.
-
-#### ZLIB
-
-```js
-// compressed = Array.<number> or Uint8Array
-var inflate = new Zlib.Inflate(compressed);
-var plain = inflate.decompress();
-```
-
-##### ZLIB Option
-
-Second argument of Zlib.Inflate constructor
-
-```js
-{
- 'index': number, // start position in input buffer
- 'bufferSize': number, // initial output buffer size
- 'bufferType': Zlib.Inflate.BufferType, // buffer expantion type
- 'resize': boolean, // resize buffer(ArrayBuffer) when end of decompression (default: false)
- 'verify': boolean // verify decompression result (default: false)
-}
-```
-
-<code>Zlib.Inflate.BufferType</code> is enumerable.
-Choose one <code>ADAPTIVE</code>(default) and <code>BLOCK</code>.
-
-- <code>ADAPTIVE</code>: buffer expansion based on compression ratio in filled buffer.
-- <code>BLOCK</code>: buffer expansion based on <code>BufferSize</code>.
-
-
-#### GZIP
-
-```js
-// compressed = Array.<number> or Uint8Array
-var gunzip = new Zlib.Gunzip(compressed);
-var plain = gunzip.decompress();
-```
-
-
-#### PKZIP
-
-
-```js
-// compressed = Array.<number> or Uint8Array
-var unzip = new Zlib.Unzip(compressed);
-var filenames = unzip.getFilenames();
-var plain = unzip.decompress(filenames[0]);
-```
-
-
-### Node.js
-
-see unit tests.
-<https://github.com/imaya/zlib.js/blob/master/test/node-test.js>
-
-
-## Debug
-
-If you want to know the code before compile, SourceMaps and PrettyPrint can be used.
-
-
-### SourceMaps
-
-If you want to enable the SourceMaps if, you can use the `src` directory and *.min.js.map.
-
- - inflate.min.js
- - inflate.min.js.map
- - [src]
- - (source files)
-
-`[src]` is zlib.js source code directory.
-
-
-### Pretty Print
-
-`zlib.pretty.js` is not renamed symbol.
-
-
-How to build
-------------
-
-Build using Ant and Closure Compiler.
-
-### Requirement
-
-- Ant 1.8+
-- JRE 1.6+
-- Python
-
-### Build
-
-Use "ant" command.
-
-```
-$ ant [target]
-```
-
-#### Build target
-
-target | generate file | implementation
----------------|----------------------|-------------
-deps | deps.js | (dependency: deps.js)
-deflate | deflate.min.js | ZLIB Deflate
-inflate | inflate.min.js | ZLIB Inflate
-inflate_stream | inlate_stream.min.js | ZLIB Inlate (stream)
-zlib | zlib.min.js | ZLIB Deflate + Inflate
-gzip | gzip.min.js | GZIP Compression
-gunzip | gunzip.min.js | GZIP Decompression
-zlib_and_gzip | zlib_and_gzip.min.js | ZLIB + GZIP
-node | node-zlib.js | ZLIB + GZIP for node.js
-zip | zip.min.js | PKZIP Compression
-unzip | unzip.min.js | PKZIP Decompression
-all | * | default target
-
-
-Issue
------
-
-Preset dictionary is not implemented.
-
-
-License
---------
-
-Copyright © 2012 imaya.
-Licensed under the MIT License.
+++ /dev/null
-zlib.js
-=======
-
-[](https://travis-ci.org/imaya/zlib.js)
-
-[English version](./README.en.md)
-
-zlib.js は ZLIB(RFC1950), DEFLATE(RFC1951), GZIP(RFC1952), PKZIP の JavaScript 実装です。
-
-
-使い方
-------
-
-zlib.js は必要な機能ごとに分割されています。
-bin ディレクトリから必要なものを利用してください。
-
-- zlib_and_gzip.min.js: ZLIB + GZIP
- + (Raw)
- * rawdeflate.js: Raw Deflate
- * rawinflate.js: Raw Inflate
- + zlib.min.js: ZLIB Inflate + Deflate
- * inflate.min.js: ZLIB Inflate
- * deflate.min.js: ZLIB Deflate
- * inflate_stream.min.js: ZLIB Inflate (stream mode)
- + (GZIP)
- * gzip.min.js: GZIP
- * gunzip.min.js: GUNZIP
- + (PKZIP)
- * zip.min.js ZIP
- * unzip.min.js UNZIP
-- node-zlib.js: (ZLIB + GZIP for node.js)
-
-
-### 圧縮 (Compress)
-
-#### Raw Deflate
-
-```js
-// plain = Array.<number> or Uint8Array
-var defalte = new Zlib.RawDeflate(plain);
-var compressed = deflate.compress();
-```
-
-#### Raw Deflate Option
-
-ZLIB Option を参照してください。
-
-
-#### ZLIB
-
-```js
-// plain = Array.<number> or Uint8Array
-var defalte = new Zlib.Deflate(plain);
-var compressed = deflate.compress();
-```
-
-##### ZLIB Option
-
-<code>Zlib.Deflate</code> の第二引数にオブジェクトを渡す事で圧縮オプションを指定する事が出来ます。
-
-```js
-{
- compressionType: Zlib.Deflate.CompressionType, // 圧縮タイプ
- lazy: number // lazy matching の閾値
-}
-```
-
-<code>Zlib.Deflate.CompressionType</code> は
-<code>NONE</code>(無圧縮), <code>FIXED</code>(固定ハフマン符号), <code>DYNAMIC</code>(動的ハフマン符号) から選択する事ができます。
-default は <code>DYNAMIC</code> です。
-
-<code>lazy</code> は Lazy Matching の閾値を指定します。
-Lazy Matching とは、LZSS のマッチ長が閾値より低かった場合、次の Byte から LZSS の最長一致を試み、マッチ長の長い方を選択する手法です。
-
-
-#### GZIP
-
-GZIP の実装は現在不完全ですが、ただの圧縮コンテナとして使用する場合には特に問題はありません。
-zlib.js を用いて作成された GZIP の OS は、自動的に UNKNOWN に設定されます。
-
-```js
-// plain = Array.<number> or Uint8Array
-var gzip = new Zlib.Gzip(plain);
-var compressed = gzip.compress();
-```
-
-
-##### GZIP Option
-
-```js
-{
- deflateOptions: Object, // deflate option (ZLIB Option 参照)
- flags: {
- fname: boolean, // ファイル名を使用するか
- comment: boolean, // コメントを使用するか
- fhcrc: boolean // FHCRC を使用するか
- },
- filename: string, // flags.fname が true のときに書き込むファイル名
- comment: string // flags.comment が true のときに書き込むコメント
-}
-```
-
-
-#### PKZIP
-
-PKZIP では複数のファイルを扱うため、他のものとは少し使い方が異なります。
-
-```js
-var zip = new Zlib.Zip();
-// plainData1
-zip.addFile(plainData1, {
- filename: stringToByteArray('foo.txt')
-});
-zip.addFile(plainData2, {
- filename: stringToByteArray('bar.txt')
-});
-zip.addFile(plainData3, {
- filename: stringToByteArray('baz.txt')
-});
-var compressed = zip.compress();
-
-function stringToByteArray(str) {
- var array = new (window.Uint8Array !== void 0 ? Uint8Array : Array)(str.length);
- var i;
- var il;
-
- for (i = 0, il = str.length; i < il; ++i) {
- array[i] = str.charCodeAt(i) & 0xff;
- }
-
- return array;
-}
-```
-
-##### PKZIP Option
-
-filename, comment, extraField は Typed Array が使用可能な場合は必ず Uint8Array を使用してください。
-
-```js
-{
- filename: (Array.<number>|Uint8Array), // ファイル名
- comment: (Array.<number>|Uint8Array), // コメント
- extraField: (Array.<number>|Uint8Array), // その他の領域
- compress: boolean, // addFile メソッドを呼んだときに圧縮するか (通常は compress メソッドの呼び出し時に圧縮)
- compressionMethod: Zlib.Zip.CompressionMethod, // STORE or DEFLATE
- os: Zlib.Zip.OperatingSystem, // MSDOS or UNIX or MACINTOSH
- deflateOption: Object // see: ZLIB Option
-}
-```
-
-### 伸張 (Decompress)
-
-圧縮されたデータの伸張は、基本的に各コンストラクタに圧縮されたデータを渡し、
-それの <code>decompress</code> メソッドを呼ぶ事で伸張処理を開始する事が出来ます。
-
-#### Raw Deflate
-
-```js
-// compressed = Array.<number> or Uint8Array
-var inflate = new Zlib.RawInflate(compressed);
-var plain = inflate.decompress();
-```
-
-#### Raw Deflate Option
-
-ZLIB Option を参照してください。
-
-#### ZLIB
-
-```js
-// compressed = Array.<number> or Uint8Array
-var inflate = new Zlib.Inflate(compressed);
-var plain = inflate.decompress();
-```
-
-##### ZLIB Option
-
-<code>Zlib.Inflate</code> の第二引数にオブジェクトを渡す事で伸張オプションを指定する事ができます。
-
-```js
-{
- 'index': number, // 入力バッファの開始位置
- 'bufferSize': number, // 出力バッファの初期サイズ
- 'bufferType': Zlib.Inflate.BufferType, // バッファの管理方法
- 'resize': boolean, // 出力バッファのリサイズ
- 'verify': boolean // 伸張結果の検証を行うか
-}
-```
-
-<code>Zlib.Inflate.BufferType</code> は <code>ADAPTIVE</code>(default) か <code>BLOCK</code> を選択する事ができます。
-
-- <code>ADAPTIVE</code> はバッファを伸張後のサイズを予測して一気に拡張しますが、データによっては余分にメモリを使用しすぎる事があります。
-- <code>BLOCK</code> では <code>BufferSize</code> ずつ拡張していきますが、動作はあまり速くありません。
-
-<code>resize</code> オプションは Typed Array 利用可能時
-<code>decompress</code> メソッドで返却する値の <code>ArrayBuffer</code> を <code>Uint8Array</code> の長さまで縮小させます。
-default は <code>false</code> です。
-
-<code>verify</code> オプションは Adler-32 Checksum の検証を行うかを指定します。
-default は <code>false</code> です。
-
-
-#### GZIP
-
-```js
-// compressed = Array.<number> or Uint8Array
-var gunzip = new Zlib.Gunzip(compressed);
-var plain = gunzip.decompress();
-```
-
-Gunzip のオプションは現在ありません。
-
-
-#### PKZIP
-
-PKZIP の構築と同様に複数ファイルを扱うため、他のものとは少し使い方が異なります。
-
-```js
-// compressed = Array.<number> or Uint8Array
-var unzip = new Zlib.Unzip(compressed);
-var filenames = unzip.getFilenames();
-var plain = unzip.decompress(filenames[0]);
-```
-
-Unzip のオプションは現在ありません。
-
-
-### Node.js
-
-Node.js で使用する場合はユニットテストを参照してください。
-<https://github.com/imaya/zlib.js/blob/master/test/node-test.js>
-
-
-## Debug
-
-zlib.js では JavaScript ファイルを minify された形で提供していますが、開発中やデバッグ時に minify する前の状態が知りたい事があります。
-そういった時のために SourceMaps ファイルや Pretty Print されたファイルも提供しています。
-
-
-### SourceMaps
-
-SourceMaps を有効にするには以下のように対象となるファイルに `.map` を付けたファイルと、変換前のソースコードである `src` ディレクトリを配置します。
-
- - inflate.min.js
- - inflate.min.js.map
- - [src]
- - (source files)
-
-なお、ここに書いてある `[src]` は zlib.js のリポジトリの `src` ディレクトリをコピーしてください。
-
-
-### Pretty Print
-
-SourceMaps とは異なりますが、minify の変数名の短縮のみ避けられれば良いという場合には、 Closure Compiler で読みやすくしたファイルを利用することも可能です。
-`zlib.pretty.js` というファイル名で全ての実装がはいっていますので、minify されたものをこのファイルに置き換えるだけで使用できます。
-
-
-
-How to build
-------------
-
-ビルドは Ant と Closure Compiler を使用して行います。
-
-### 必要な環境
-
-- Ant 1.8+
-- JRE 1.6+
-- Python
-
-### ビルド
-
-Ant を使ってビルドを行います。
-
-```
-$ ant [target]
-```
-
-#### ビルドターゲット
-
-target | ファイル名 | 含まれる実装
----------------|----------------------|-------------
-deps | deps.js | 依存関係の解決
-deflate | deflate.min.js | ZLIB Deflate
-inflate | inflate.min.js | ZLIB Inflate
-inflate_stream | inlate_stream.min.js | ZLIB Inlate (stream)
-zlib | zlib.min.js | ZLIB Deflate + Inflate
-gzip | gzip.min.js | GZIP Compression
-gunzip | gunzip.min.js | GZIP Decompression
-zlib_and_gzip | zlib_and_gzip.min.js | ZLIB + GZIP
-node | node-zlib.js | ZLIB + GZIP for node.js
-zip | zip.min.js | PKZIP Compression
-unzip | unzip.min.js | PKZIP Decompression
-all | * | default target
-
-
-Issue
------
-
-現在プリセット辞書を用いた圧縮形式には対応していません。
-プリセット辞書は通常の圧縮では利用されないため、影響は少ないと思います。
-
-
-ライセンス
------------
-
-Copyright © 2012 imaya.
-Licensed under the MIT License.
+++ /dev/null
-/** @license zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */(function() {'use strict';var l=void 0,p=this;function q(c,d){var a=c.split("."),b=p;!(a[0]in b)&&b.execScript&&b.execScript("var "+a[0]);for(var e;a.length&&(e=a.shift());)!a.length&&d!==l?b[e]=d:b=b[e]?b[e]:b[e]={}};var r="undefined"!==typeof Uint8Array&&"undefined"!==typeof Uint16Array&&"undefined"!==typeof Uint32Array;function u(c){var d=c.length,a=0,b=Number.POSITIVE_INFINITY,e,f,g,h,k,m,s,n,t;for(n=0;n<d;++n)c[n]>a&&(a=c[n]),c[n]<b&&(b=c[n]);e=1<<a;f=new (r?Uint32Array:Array)(e);g=1;h=0;for(k=2;g<=a;){for(n=0;n<d;++n)if(c[n]===g){m=0;s=h;for(t=0;t<g;++t)m=m<<1|s&1,s>>=1;for(t=m;t<e;t+=k)f[t]=g<<16|n;++h}++g;h<<=1;k<<=1}return[f,a,b]};function v(c,d){this.g=[];this.h=32768;this.c=this.f=this.d=this.k=0;this.input=r?new Uint8Array(c):c;this.l=!1;this.i=w;this.p=!1;if(d||!(d={}))d.index&&(this.d=d.index),d.bufferSize&&(this.h=d.bufferSize),d.bufferType&&(this.i=d.bufferType),d.resize&&(this.p=d.resize);switch(this.i){case x:this.a=32768;this.b=new (r?Uint8Array:Array)(32768+this.h+258);break;case w:this.a=0;this.b=new (r?Uint8Array:Array)(this.h);this.e=this.u;this.m=this.r;this.j=this.s;break;default:throw Error("invalid inflate mode");
-}}var x=0,w=1;
-v.prototype.t=function(){for(;!this.l;){var c=y(this,3);c&1&&(this.l=!0);c>>>=1;switch(c){case 0:var d=this.input,a=this.d,b=this.b,e=this.a,f=l,g=l,h=l,k=b.length,m=l;this.c=this.f=0;f=d[a++];if(f===l)throw Error("invalid uncompressed block header: LEN (first byte)");g=f;f=d[a++];if(f===l)throw Error("invalid uncompressed block header: LEN (second byte)");g|=f<<8;f=d[a++];if(f===l)throw Error("invalid uncompressed block header: NLEN (first byte)");h=f;f=d[a++];if(f===l)throw Error("invalid uncompressed block header: NLEN (second byte)");h|=
-f<<8;if(g===~h)throw Error("invalid uncompressed block header: length verify");if(a+g>d.length)throw Error("input buffer is broken");switch(this.i){case x:for(;e+g>b.length;){m=k-e;g-=m;if(r)b.set(d.subarray(a,a+m),e),e+=m,a+=m;else for(;m--;)b[e++]=d[a++];this.a=e;b=this.e();e=this.a}break;case w:for(;e+g>b.length;)b=this.e({o:2});break;default:throw Error("invalid inflate mode");}if(r)b.set(d.subarray(a,a+g),e),e+=g,a+=g;else for(;g--;)b[e++]=d[a++];this.d=a;this.a=e;this.b=b;break;case 1:this.j(z,
-A);break;case 2:B(this);break;default:throw Error("unknown BTYPE: "+c);}}return this.m()};
-var C=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],D=r?new Uint16Array(C):C,E=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258],F=r?new Uint16Array(E):E,G=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0],H=r?new Uint8Array(G):G,I=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],J=r?new Uint16Array(I):I,K=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,
-13],L=r?new Uint8Array(K):K,M=new (r?Uint8Array:Array)(288),N,O;N=0;for(O=M.length;N<O;++N)M[N]=143>=N?8:255>=N?9:279>=N?7:8;var z=u(M),P=new (r?Uint8Array:Array)(30),Q,R;Q=0;for(R=P.length;Q<R;++Q)P[Q]=5;var A=u(P);function y(c,d){for(var a=c.f,b=c.c,e=c.input,f=c.d,g;b<d;){g=e[f++];if(g===l)throw Error("input buffer is broken");a|=g<<b;b+=8}g=a&(1<<d)-1;c.f=a>>>d;c.c=b-d;c.d=f;return g}
-function S(c,d){for(var a=c.f,b=c.c,e=c.input,f=c.d,g=d[0],h=d[1],k,m,s;b<h;){k=e[f++];if(k===l)break;a|=k<<b;b+=8}m=g[a&(1<<h)-1];s=m>>>16;c.f=a>>s;c.c=b-s;c.d=f;return m&65535}
-function B(c){function d(a,c,b){var d,f,e,g;for(g=0;g<a;)switch(d=S(this,c),d){case 16:for(e=3+y(this,2);e--;)b[g++]=f;break;case 17:for(e=3+y(this,3);e--;)b[g++]=0;f=0;break;case 18:for(e=11+y(this,7);e--;)b[g++]=0;f=0;break;default:f=b[g++]=d}return b}var a=y(c,5)+257,b=y(c,5)+1,e=y(c,4)+4,f=new (r?Uint8Array:Array)(D.length),g,h,k,m;for(m=0;m<e;++m)f[D[m]]=y(c,3);g=u(f);h=new (r?Uint8Array:Array)(a);k=new (r?Uint8Array:Array)(b);c.j(u(d.call(c,a,g,h)),u(d.call(c,b,g,k)))}
-v.prototype.j=function(c,d){var a=this.b,b=this.a;this.n=c;for(var e=a.length-258,f,g,h,k;256!==(f=S(this,c));)if(256>f)b>=e&&(this.a=b,a=this.e(),b=this.a),a[b++]=f;else{g=f-257;k=F[g];0<H[g]&&(k+=y(this,H[g]));f=S(this,d);h=J[f];0<L[f]&&(h+=y(this,L[f]));b>=e&&(this.a=b,a=this.e(),b=this.a);for(;k--;)a[b]=a[b++-h]}for(;8<=this.c;)this.c-=8,this.d--;this.a=b};
-v.prototype.s=function(c,d){var a=this.b,b=this.a;this.n=c;for(var e=a.length,f,g,h,k;256!==(f=S(this,c));)if(256>f)b>=e&&(a=this.e(),e=a.length),a[b++]=f;else{g=f-257;k=F[g];0<H[g]&&(k+=y(this,H[g]));f=S(this,d);h=J[f];0<L[f]&&(h+=y(this,L[f]));b+k>e&&(a=this.e(),e=a.length);for(;k--;)a[b]=a[b++-h]}for(;8<=this.c;)this.c-=8,this.d--;this.a=b};
-v.prototype.e=function(){var c=new (r?Uint8Array:Array)(this.a-32768),d=this.a-32768,a,b,e=this.b;if(r)c.set(e.subarray(32768,c.length));else{a=0;for(b=c.length;a<b;++a)c[a]=e[a+32768]}this.g.push(c);this.k+=c.length;if(r)e.set(e.subarray(d,d+32768));else for(a=0;32768>a;++a)e[a]=e[d+a];this.a=32768;return e};
-v.prototype.u=function(c){var d,a=this.input.length/this.d+1|0,b,e,f,g=this.input,h=this.b;c&&("number"===typeof c.o&&(a=c.o),"number"===typeof c.q&&(a+=c.q));2>a?(b=(g.length-this.d)/this.n[2],f=258*(b/2)|0,e=f<h.length?h.length+f:h.length<<1):e=h.length*a;r?(d=new Uint8Array(e),d.set(h)):d=h;return this.b=d};
-v.prototype.m=function(){var c=0,d=this.b,a=this.g,b,e=new (r?Uint8Array:Array)(this.k+(this.a-32768)),f,g,h,k;if(0===a.length)return r?this.b.subarray(32768,this.a):this.b.slice(32768,this.a);f=0;for(g=a.length;f<g;++f){b=a[f];h=0;for(k=b.length;h<k;++h)e[c++]=b[h]}f=32768;for(g=this.a;f<g;++f)e[c++]=d[f];this.g=[];return this.buffer=e};
-v.prototype.r=function(){var c,d=this.a;r?this.p?(c=new Uint8Array(d),c.set(this.b.subarray(0,d))):c=this.b.subarray(0,d):(this.b.length>d&&(this.b.length=d),c=this.b);return this.buffer=c};q("Zlib.RawInflate",v);q("Zlib.RawInflate.prototype.decompress",v.prototype.t);var T={ADAPTIVE:w,BLOCK:x},U,V,W,X;if(Object.keys)U=Object.keys(T);else for(V in U=[],W=0,T)U[W++]=V;W=0;for(X=U.length;W<X;++W)V=U[W],q("Zlib.RawInflate.BufferType."+V,T[V]);}).call(this); //@ sourceMappingURL=rawinflate.min.js.map
+++ /dev/null
-{
-"version":3,
-"file":"./bin/rawinflate.min.js",
-"lineCount":15,
-"mappings":"A,mHAAA,aA4CAA,EAAc,IA0HKC,SAAQ,EAAA,CAACC,CAAD,CAAOC,CAAP,CAAyC,CAClE,IAAIC,EAAQF,CAAAG,MAAA,CAAW,GAAX,CAAZ,CACIC,EAA8BN,CAK9B,GAAEI,CAAA,CAAM,CAAN,CAAF,EAAcE,EAAd,CAAJ,EAA0BA,CAAAC,WAA1B,EACED,CAAAC,WAAA,CAAe,MAAf,CAAwBH,CAAA,CAAM,CAAN,CAAxB,CASF,KAAK,IAAII,CAAT,CAAeJ,CAAAK,OAAf,GAAgCD,CAAhC,CAAuCJ,CAAAM,MAAA,EAAvC,EAAA,CACM,CAACN,CAAAK,OAAL,EAAgCN,CAAhC,GAyjBaQ,CAzjBb,CAEEL,CAAA,CAAIE,CAAJ,CAFF,CAEcL,CAFd,CAIEG,CAJF,CAGWA,CAAA,CAAIE,CAAJ,CAAJ,CACCF,CAAA,CAAIE,CAAJ,CADD,CAGCF,CAAA,CAAIE,CAAJ,CAHD,CAGa,EAxB4C,C,CC5JpE,IAAII,EACqB,WADrBA,GACD,MAAOC,WADND,EAEsB,WAFtBA,G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,C,CHwhBzD9G,CAAA,CIt1CgB+H,iBJs1ChB,CIt1CmC/F,CJs1CnC,CAAAhC,EAAA,CIp1CA+H,sCJo1CA,CIn1CA/F,CAAA4B,UAAAC,EJm1CA,CIj1C8C,KAAA,EAAA,UAClCjB,CADkC,OAErCE,CAFqC,CAAA,CCA1CkF,CDA0C,CCE1CC,CDF0C,CCI1CpG,CDJ0C,CCM1CoD,CAEJ,IAAIiD,MAAAF,KAAJ,CACEA,CAAA,CAAOE,MAAAF,KAAA,CAAYG,CAAZ,CADT,KAKE,KAAKF,CAAL,GAFAD,EAEYG,CAFL,EAEKA,CADZtG,CACYsG,CADR,CACQA,CAAAA,CAAZ,CACEH,CAAA,CAAKnG,CAAA,EAAL,CAAA,CAAYoG,CAIXpG,EAAA,CAAI,CAAT,KAAYoD,CAAZ,CAAiB+C,CAAAxH,OAAjB,CAA8BqB,CAA9B,CAAkCoD,CAAlC,CAAsC,EAAEpD,CAAxC,CACEoG,CL8zCF,CK9zCQD,CAAA,CAAKnG,CAAL,CL8zCR,CAAA7B,CAAA,CK7zCoB,6BL6zCpB,CK7zCuCiI,CL6zCvC,CK7zC4CE,CAAAC,CAAeH,CAAfG,CL6zC5C;",
-"sources":["closure-primitives/base.js","./define/typedarray/hybrid.js","./src/huffman.js","./src/rawinflate.js","./export/rawinflate.js","./src/export_object.js"],
-"names":["goog.global","goog.exportPath_","name","opt_object","parts","split","cur","execScript","part","length","shift","JSCompiler_alias_VOID","USE_TYPEDARRAY","Uint8Array","Uint16Array","Uint32Array","Zlib.Huffman.buildHuffmanTable","lengths","listSize","maxCodeLength","minCodeLength","Number","POSITIVE_INFINITY","size","table","bitLength","code","skip","reversed","rtemp","i","j","Array","Zlib.RawInflate","input","opt_params","blocks","bufferSize","ZLIB_RAW_INFLATE_BUFFER_SIZE","bitsbuflen","bitsbuf","ip","totalpos","bfinal","bufferType","Zlib.RawInflate.BufferType.ADAPTIVE","resize","Zlib.RawInflate.BufferType.BLOCK","op","Zlib.RawInflate.MaxBackwardLength","output","Zlib.RawInflate.MaxCopyLength","expandBuffer","expandBufferAdaptive","concatBuffer","concatBufferDynamic","decodeHuffman","decodeHuffmanAdaptive","Error","BLOCK","ADAPTIVE","prototype","decompress","Zlib.RawInflate.prototype.decompress","hdr","readBits","parseBlock","octet","len","nlen","olength","preCopy","set","subarray","Zlib.RawInflate.FixedLiteralLengthTable","Zlib.RawInflate.FixedDistanceTable","parseDynamicHuffmanBlock","Zlib.RawInflate.Order","Zlib.RawInflate.LengthCodeTable","Zlib.RawInflate.LengthExtraTable","Zlib.RawInflate.DistCodeTable","Zlib.RawInflate.DistExtraTable","il","Zlib.RawInflate.prototype.readBits","Zlib.RawInflate.prototype.readCodeByTable","codeTable","codeWithLength","codeLength","Zlib.RawInflate.prototype.parseDynamicHuffmanBlock","decode","num","prev","repeat","readCodeByTable","hlit","hdist","hclen","codeLengths","Zlib.RawInflate.Order.length","codeLengthsTable","litlenLengths","distLengths","call","Zlib.RawInflate.prototype.decodeHuffman","litlen","dist","currentLitlenTable","ti","codeDist","Zlib.RawInflate.prototype.decodeHuffmanAdaptive","Zlib.RawInflate.prototype.expandBuffer","buffer","backward","push","Zlib.RawInflate.prototype.expandBufferAdaptive","opt_param","ratio","maxHuffCode","newSize","maxInflateSize","fixRatio","addRatio","Zlib.RawInflate.prototype.concatBuffer","pos","block","jl","slice","Zlib.RawInflate.prototype.concatBufferDynamic","publicPath","keys","key","Object","exportKeyValue","object"]
-}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<project name="project" default="all">
- <!--
- <property name="level" value="ADVANCED_OPTIMIZATIONS"/>
- -->
- <property name="level" value="PERFORMANCE_OPTIMIZATIONS"/>
- <property name="src" value="./src"/>
- <property name="def" value="./define"/>
- <property name="vendor" value="./vendor"/>
- <property name="bin" value="./bin"/>
- <property name="compiler" value="${vendor}/google-closure-compiler/compiler.jar"/>
- <property name="closure_primitives" value="closure-primitives/base.js"/>
- <property name="depswriter" value="closure-primitives/depswriter.py"/>
- <property name="depend" value="deps.js"/>
- <property name="export" value="./export"/>
- <property name="basedir" location="."/>
-
- <!-- ライセンスとビルドされたファイルをプロパティとして読み込む -->
- <loadfile property="license" srcfile="./LICENSE_min"/>
-
- <!-- ビルドの事前準備 -->
- <target name="prebuild" description="ビルドの事前準備を行う">
- <mkdir dir="${bin}"/>
- </target>
-
- <!-- 依存関係を解決する -->
- <target name="deps" description="依存関係を解決する">
- <exec executable="python" failonerror="true">
- <arg line="${depswriter}"/>
- <arg line="--root_with_prefix=". ..""/>
- <arg line="--output_file=${depend}"/>
- </exec>
- <pathconvert property="srcfiles" pathsep=" ">
- <map from="${basedir}" to="--js ."/>
- <fileset dir="${src}" includes="*.js"/>
- </pathconvert>
- <echo message="${srcfiles}"/>
-
- <pathconvert property="exportfiles" pathsep=" ">
- <map from="${basedir}" to="--js ."/>
- <fileset dir="${export}" includes="*.js"/>
- </pathconvert>
- <echo message="${exportfiles}"/>
- </target>
-
- <!-- RawInflate の単体ビルド -->
- <target name="raw_inflate" depends="deps,prebuild" description="Inflate の独立ビルドを行う">
- <!-- 出力ファイル名 -->
- <local name="basename"/>
- <property name="basename" value="rawinflate.min.js"/>
- <local name="outfile"/>
- <property name="outfile" value="${bin}/${basename}"/>
- <!-- ビルド(出力先は一時ファイル) -->
- <java jar="${compiler}" fork="true" failonerror="true">
- <arg line="--compilation_level=${level}"/>
- <arg line="--warning_level=VERBOSE"/>
- <arg line="--define=goog.DEBUG=false"/>
- <arg line="--summary_detail_level=3"/>
- <arg line="--language_in=ECMASCRIPT5_STRICT"/>
- <arg line="--source_map_format=V3"/>
- <arg line="--output_wrapper='${license}(function() {%output%}).call(this); //@ sourceMappingURL=${basename}.map'"/>
- <arg line="--js_output_file=${outfile}"/>
- <arg line="--create_source_map=${outfile}.map"/>
- <arg line="--manage_closure_dependencies"/>
- <arg line="--js=${closure_primitives}"/>
- <arg line="--js=${depend}"/>
- <arg line="--js=${def}/typedarray/hybrid.js"/>
- <arg line="${srcfiles}"/>
- <arg line="--js=${export}/rawinflate.js"/>
- </java>
- </target>
-
- <!-- RawInflate の単体ビルド -->
- <target name="raw_deflate" depends="deps,prebuild" description="Deflate の独立ビルドを行う">
- <!-- 出力ファイル名 -->
- <local name="basename"/>
- <property name="basename" value="rawdeflate.min.js"/>
- <local name="outfile"/>
- <property name="outfile" value="${bin}/${basename}"/>
- <!-- ビルド(出力先は一時ファイル) -->
- <java jar="${compiler}" fork="true" failonerror="true">
- <arg line="--compilation_level=${level}"/>
- <arg line="--warning_level=VERBOSE"/>
- <arg line="--define=goog.DEBUG=false"/>
- <arg line="--summary_detail_level=3"/>
- <arg line="--language_in=ECMASCRIPT5_STRICT"/>
- <arg line="--source_map_format=V3"/>
- <arg line="--output_wrapper='${license}(function() {%output%}).call(this); //@ sourceMappingURL=${basename}.map'"/>
- <arg line="--js_output_file=${outfile}"/>
- <arg line="--create_source_map=${outfile}.map"/>
- <arg line="--manage_closure_dependencies"/>
- <arg line="--js=${export}/rawdeflate.js"/>
- <arg line="--js=${closure_primitives}"/>
- <arg line="--js=${depend}"/>
- <arg line="--js=${def}/typedarray/hybrid.js"/>
- <arg line="${srcfiles}"/>
- </java>
- </target>
-
- <!-- Inflate の単体ビルド -->
- <target name="inflate" depends="deps,prebuild" description="Inflate の独立ビルドを行う">
- <!-- 出力ファイル名 -->
- <local name="basename"/>
- <property name="basename" value="inflate.min.js"/>
- <local name="outfile"/>
- <property name="outfile" value="${bin}/${basename}"/>
- <!-- ビルド(出力先は一時ファイル) -->
- <java jar="${compiler}" fork="true" failonerror="true">
- <arg line="--compilation_level=${level}"/>
- <arg line="--warning_level=VERBOSE"/>
- <arg line="--define=goog.DEBUG=false"/>
- <arg line="--summary_detail_level=3"/>
- <arg line="--language_in=ECMASCRIPT5_STRICT"/>
- <arg line="--source_map_format=V3"/>
- <arg line="--output_wrapper='${license}(function() {%output%}).call(this); //@ sourceMappingURL=${basename}.map'"/>
- <arg line="--js_output_file=${outfile}"/>
- <arg line="--create_source_map=${outfile}.map"/>
- <arg line="--manage_closure_dependencies"/>
- <arg line="--js=${export}/inflate.js"/>
- <arg line="--js=${closure_primitives}"/>
- <arg line="--js=${depend}"/>
- <arg line="--js=${def}/typedarray/hybrid.js"/>
- <arg line="${srcfiles}"/>
- </java>
- </target>
-
- <!-- Inflate(Stream版) の単体ビルド -->
- <target name="inflate_stream" depends="deps,prebuild" description="Inflate(Stream版) の独立ビルドを行う">
- <!-- 出力ファイル名 -->
- <local name="basename"/>
- <property name="basename" value="inflate_stream.min.js"/>
- <local name="outfile"/>
- <property name="outfile" value="${bin}/${basename}"/>
- <!-- ビルド(出力先は一時ファイル) -->
- <java jar="${compiler}" fork="true" failonerror="true">
- <arg line="--compilation_level=${level}"/>
- <arg line="--warning_level=VERBOSE"/>
- <arg line="--define=goog.DEBUG=false"/>
- <arg line="--summary_detail_level=3"/>
- <arg line="--language_in=ECMASCRIPT5_STRICT"/>
- <arg line="--source_map_format=V3"/>
- <arg line="--output_wrapper='${license}(function() {%output%}).call(this); //@ sourceMappingURL=${basename}.map'"/>
- <arg line="--js_output_file=${outfile}"/>
- <arg line="--create_source_map=${outfile}.map"/>
- <arg line="--manage_closure_dependencies"/>
- <arg line="--js=${export}/inflate_stream.js"/>
- <arg line="--js=${closure_primitives}"/>
- <arg line="--js=${depend}"/>
- <arg line="--js=${def}/typedarray/hybrid.js"/>
- <arg line="${srcfiles}"/>
- </java>
- </target>
-
- <!-- Gzip の単体ビルド -->
- <target name="gzip" depends="deps,prebuild" description="Gzip の独立ビルドを行う">
- <!-- 出力ファイル名 -->
- <local name="basename"/>
- <property name="basename" value="gzip.min.js"/>
- <local name="outfile"/>
- <property name="outfile" value="${bin}/${basename}"/>
- <!-- ビルド(出力先は一時ファイル) -->
- <java jar="${compiler}" fork="true" failonerror="true">
- <arg line="--compilation_level=${level}"/>
- <arg line="--warning_level=VERBOSE"/>
- <arg line="--define=goog.DEBUG=false"/>
- <arg line="--summary_detail_level=3"/>
- <arg line="--language_in=ECMASCRIPT5_STRICT"/>
- <arg line="--source_map_format=V3"/>
- <arg line="--output_wrapper='(function() {%output%}).call(this);'"/>
- <arg line="--js_output_file=${outfile}"/>
- <arg line="--create_source_map=${outfile}.map"/>
- <arg line="--manage_closure_dependencies"/>
- <arg line="--js=${export}/gzip.js"/>
- <arg line="--js=${closure_primitives}"/>
- <arg line="--js=${depend}"/>
- <arg line="--js=${def}/typedarray/hybrid.js"/>
- <arg line="${srcfiles}"/>
- </java>
- </target>
-
- <!-- Gunzip の単体ビルド -->
- <target name="gunzip" depends="deps,prebuild" description="Inflate の独立ビルドを行う">
- <!-- 出力ファイル名 -->
- <local name="basename"/>
- <property name="basename" value="gunzip.min.js"/>
- <local name="outfile"/>
- <property name="outfile" value="${bin}/${basename}"/>
- <!-- ビルド(出力先は一時ファイル) -->
- <java jar="${compiler}" fork="true" failonerror="true">
- <arg line="--compilation_level=${level}"/>
- <arg line="--warning_level=VERBOSE"/>
- <arg line="--define=goog.DEBUG=false"/>
- <arg line="--summary_detail_level=3"/>
- <arg line="--language_in=ECMASCRIPT5_STRICT"/>
- <arg line="--source_map_format=V3"/>
- <arg line="--output_wrapper='${license}(function() {%output%}).call(this); //@ sourceMappingURL=${basename}.map'"/>
- <arg line="--js_output_file=${outfile}"/>
- <arg line="--create_source_map=${outfile}.map"/>
- <arg line="--manage_closure_dependencies"/>
- <arg line="--js=${export}/gunzip.js"/>
- <arg line="--js=${export}/gunzip_member.js"/>
- <arg line="--js=${closure_primitives}"/>
- <arg line="--js=${depend}"/>
- <arg line="--js=${def}/typedarray/hybrid.js"/>
- <arg line="${srcfiles}"/>
- </java>
- </target>
-
- <!-- Deflate の単体ビルド -->
- <target name="deflate" depends="deps,prebuild" description="Deflate の独立ビルドを行う">
- <!-- 出力ファイル名 -->
- <local name="basename"/>
- <property name="basename" value="deflate.min.js"/>
- <local name="outfile"/>
- <property name="outfile" value="${bin}/${basename}"/>
- <!-- ビルド(出力先は一時ファイル) -->
- <java jar="${compiler}" fork="true" failonerror="true">
- <arg line="--compilation_level=${level}"/>
- <arg line="--warning_level=VERBOSE"/>
- <arg line="--define=goog.DEBUG=false"/>
- <arg line="--summary_detail_level=3"/>
- <arg line="--language_in=ECMASCRIPT5_STRICT"/>
- <arg line="--source_map_format=V3"/>
- <arg line="--output_wrapper='${license}(function() {%output%}).call(this); //@ sourceMappingURL=${basename}.map'"/>
- <arg line="--js_output_file=${outfile}"/>
- <arg line="--create_source_map=${outfile}.map"/>
- <arg line="--manage_closure_dependencies"/>
- <arg line="--js=${export}/deflate.js"/>
- <arg line="--js=${closure_primitives}"/>
- <arg line="--js=${depend}"/>
- <arg line="--js=${def}/typedarray/hybrid.js"/>
- <arg line="${srcfiles}"/>
- </java>
- </target>
-
- <!-- Zlib のビルド -->
- <target name="zlib" depends="deps,prebuild" description="リリース版のファイル zlib.min.js を作成する">
- <!-- 出力ファイル名 -->
- <local name="basename"/>
- <property name="basename" value="zlib.min.js"/>
- <local name="outfile"/>
- <property name="outfile" value="${bin}/${basename}"/>
- <!-- ビルド(出力先は一時ファイル) -->
- <java jar="${compiler}" fork="true" failonerror="true">
- <arg line="--compilation_level=${level}"/>
- <arg line="--warning_level=VERBOSE"/>
- <arg line="--define=goog.DEBUG=false"/>
- <arg line="--summary_detail_level=3"/>
- <arg line="--language_in=ECMASCRIPT5_STRICT"/>
- <arg line="--source_map_format=V3"/>
- <arg line="--output_wrapper='${license}(function() {%output%}).call(this); //@ sourceMappingURL=${basename}.map'"/>
- <arg line="--js_output_file=${outfile}"/>
- <arg line="--create_source_map=${outfile}.map"/>
- <arg line="--manage_closure_dependencies"/>
- <arg line="--js=${export}/inflate.js"/>
- <arg line="--js=${export}/deflate.js"/>
- <arg line="--js=${closure_primitives}"/>
- <arg line="--js=${depend}"/>
- <arg line="--js=${def}/typedarray/hybrid.js"/>
- <arg line="${srcfiles}"/>
- </java>
- </target>
-
- <!-- Zlib のビルド -->
- <target name="zlib_and_gzip" depends="deps,prebuild" description="リリース版のファイル zlib_and_gzip.min.js を作成する">
- <!-- 出力ファイル名 -->
- <local name="basename"/>
- <property name="basename" value="zlib_and_gzip.min.js"/>
- <local name="outfile"/>
- <property name="outfile" value="${bin}/${basename}"/>
- <!-- ビルド(出力先は一時ファイル) -->
- <java jar="${compiler}" fork="true" failonerror="true">
- <arg line="--compilation_level=${level}"/>
- <arg line="--warning_level=VERBOSE"/>
- <arg line="--define=goog.DEBUG=false"/>
- <arg line="--summary_detail_level=3"/>
- <arg line="--language_in=ECMASCRIPT5_STRICT"/>
- <arg line="--source_map_format=V3"/>
- <arg line="--output_wrapper='${license}(function() {%output%}).call(this); //@ sourceMappingURL=${basename}.map'"/>
- <arg line="--js_output_file=${outfile}"/>
- <arg line="--create_source_map=${outfile}.map"/>
- <arg line="--manage_closure_dependencies"/>
- <arg line="--js=${export}/inflate.js"/>
- <arg line="--js=${export}/deflate.js"/>
- <arg line="--js=${export}/gunzip.js"/>
- <arg line="--js=${export}/gunzip_member.js"/>
- <arg line="--js=${export}/gzip.js"/>
- <arg line="--js=${closure_primitives}"/>
- <arg line="--js=${depend}"/>
- <arg line="--js=${def}/typedarray/hybrid.js"/>
- <arg line="${srcfiles}"/>
- </java>
- </target>
-
- <!-- Node.js 版 Zlib のビルド -->
- <target name="node" depends="deps,prebuild" description="create node.js version">
- <!-- 出力ファイル名 -->
- <local name="basename"/>
- <property name="basename" value="node-zlib.js"/>
- <local name="outfile"/>
- <property name="outfile" value="${bin}/${basename}"/>
- <!-- ビルド(出力先は一時ファイル) -->
- <java jar="${compiler}" fork="true" failonerror="true">
- <arg line="--compilation_level=${level}"/>
- <arg line="--warning_level=VERBOSE"/>
- <arg line="--define=goog.DEBUG=false"/>
- <arg line="--summary_detail_level=3"/>
- <arg line="--language_in=ECMASCRIPT5_STRICT"/>
- <arg line="--source_map_format=V3"/>
- <arg line="--output_wrapper='${license}(function() {%output%}).call(this); //@ sourceMappingURL=${basename}.map'"/>
- <arg line="--externs=node/externs.js"/>
- <arg line="--js_output_file=${outfile}"/>
- <arg line="--create_source_map=${outfile}.map"/>
- <arg line="--manage_closure_dependencies"/>
- <arg line="--js=${closure_primitives}"/>
- <arg line="--js=${depend}"/>
- <arg line="--js=node/exports.js"/>
- <arg line="--js=${def}/typedarray/hybrid.js"/>
- <arg line="${srcfiles}"/>
- </java>
- </target>
-
- <!-- Unzip の単体ビルド -->
- <target name="unzip" depends="deps,prebuild" description="Unzip の独立ビルドを行う">
- <!-- 出力ファイル名 -->
- <local name="basename"/>
- <property name="basename" value="unzip.min.js"/>
- <local name="outfile"/>
- <property name="outfile" value="${bin}/${basename}"/>
- <!-- ビルド(出力先は一時ファイル) -->
- <java jar="${compiler}" fork="true" failonerror="true">
- <arg line="--compilation_level=${level}"/>
- <arg line="--warning_level=VERBOSE"/>
- <arg line="--define=goog.DEBUG=false"/>
- <arg line="--summary_detail_level=3"/>
- <arg line="--language_in=ECMASCRIPT5_STRICT"/>
- <arg line="--source_map_format=V3"/>
- <arg line="--output_wrapper='${license}(function() {%output%}).call(this); //@ sourceMappingURL=${basename}.map'"/>
- <arg line="--js_output_file=${outfile}"/>
- <arg line="--create_source_map=${outfile}.map"/>
- <arg line="--manage_closure_dependencies"/>
- <arg line="--js=${closure_primitives}"/>
- <arg line="--js=${depend}"/>
- <arg line="--js=${def}/typedarray/hybrid.js"/>
- <arg line="${export}/unzip.js"/>
- <arg line="${srcfiles}"/>
- </java>
- </target>
-
- <!-- Zip の単体ビルド -->
- <target name="zip" depends="deps,prebuild" description="Zip の独立ビルドを行う">
- <!-- 出力ファイル名 -->
- <local name="basename"/>
- <property name="basename" value="zip.min.js"/>
- <local name="outfile"/>
- <property name="outfile" value="${bin}/${basename}"/>
- <!-- ビルド(出力先は一時ファイル) -->
- <java jar="${compiler}" fork="true" failonerror="true">
- <arg line="--compilation_level=${level}"/>
- <arg line="--warning_level=VERBOSE"/>
- <arg line="--define=goog.DEBUG=false"/>
- <arg line="--summary_detail_level=3"/>
- <arg line="--language_in=ECMASCRIPT5_STRICT"/>
- <arg line="--source_map_format=V3"/>
- <arg line="--output_wrapper='${license}(function() {%output%}).call(this); //@ sourceMappingURL=${basename}.map'"/>
- <arg line="--js_output_file=${outfile}"/>
- <arg line="--create_source_map=${outfile}.map"/>
- <arg line="--manage_closure_dependencies"/>
- <arg line="--js=${closure_primitives}"/>
- <arg line="--js=${depend}"/>
- <arg line="--js=${def}/typedarray/hybrid.js"/>
- <arg line="${export}/zip.js"/>
- <arg line="${srcfiles}"/>
- </java>
- </target>
-
- <!-- CRC32 の単体ビルド -->
- <target name="crc32" depends="deps,prebuild" description="CRC32 の独立ビルドを行う">
- <!-- 出力ファイル名 -->
- <local name="basename"/>
- <property name="basename" value="crc32.min.js"/>
- <local name="outfile"/>
- <property name="outfile" value="${bin}/${basename}"/>
- <!-- ビルド(出力先は一時ファイル) -->
- <java jar="${compiler}" fork="true" failonerror="true">
- <arg line="--compilation_level=${level}"/>
- <arg line="--warning_level=VERBOSE"/>
- <arg line="--define=goog.DEBUG=false"/>
- <arg line="--summary_detail_level=3"/>
- <arg line="--language_in=ECMASCRIPT5_STRICT"/>
- <arg line="--source_map_format=V3"/>
- <arg line="--output_wrapper='${license}(function() {%output%}).call(this); //@ sourceMappingURL=${basename}.map'"/>
- <arg line="--js_output_file=${outfile}"/>
- <arg line="--create_source_map=${outfile}.map"/>
- <arg line="--manage_closure_dependencies"/>
- <arg line="--js=${closure_primitives}"/>
- <arg line="--js=${depend}"/>
- <arg line="--js=${def}/typedarray/hybrid.js"/>
- <arg line="${export}/crc32.js"/>
- <arg line="${srcfiles}"/>
- </java>
- </target>
-
- <!-- 全てのビルド(デバッグ) -->
- <target name="pretty" depends="deps,prebuild" description="デバッグ用に pretty print したもののビルドを行う">
- <!-- 出力ファイル名 -->
- <local name="basename"/>
- <property name="basename" value="zlib.pretty.js"/>
- <local name="outfile"/>
- <property name="outfile" value="${bin}/${basename}"/>
- <!-- ビルド(出力先は一時ファイル) -->
- <java jar="${compiler}" fork="true" failonerror="true">
- <arg line="--compilation_level=WHITESPACE_ONLY"/>
- <arg line="--formatting PRETTY_PRINT"/>
- <arg line="--warning_level=VERBOSE"/>
- <arg line="--define=goog.DEBUG=false"/>
- <arg line="--summary_detail_level=3"/>
- <arg line="--language_in=ECMASCRIPT5_STRICT"/>
- <arg line="--source_map_format=V3"/>
- <arg line="--output_wrapper='${license}(function() {%output%}).call(this); //@ sourceMappingURL=${basename}.map'"/>
- <arg line="--js_output_file=${outfile}"/>
- <arg line="--create_source_map=${outfile}.map"/>
- <arg line="--manage_closure_dependencies"/>
- <arg line="--js=${closure_primitives}"/>
- <arg line="--js=${depend}"/>
- <arg line="--js=${def}/typedarray/hybrid.js"/>
- <arg line="${srcfiles}"/>
- <arg line="${exportfiles}"/>
- </java>
- </target>
-
- <!-- compiler help -->
- <target name="help">
- <java jar="${compiler}" fork="true" failonerror="true">
- <arg line="--help"/>
- </java>
- </target>
-
- <!-- 全て作成 -->
- <target name="all" depends="raw_deflate,raw_inflate,zlib,zlib_and_gzip,inflate,inflate_stream,deflate,gzip,gunzip,zip,unzip,node" />
-
- <!-- 削除 -->
- <target name="clean">
- <delete file="${depend}"/>
- <delete dir="${bin}"/>
- </target>
-
- <!-- リビルド -->
- <target name="rebuild" depends="clean,all"/>
-</project>
-<!-- vim: set expandtab ts=2 sw=2: -->
+++ /dev/null
-// Copyright 2006 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Bootstrap for the Google JS Library (Closure).
- *
- * In uncompiled mode base.js will write out Closure's deps file, unless the
- * global <code>CLOSURE_NO_DEPS</code> is set to true. This allows projects to
- * include their own deps file(s) from different locations.
- *
- */
-
-
-/**
- * @define {boolean} Overridden to true by the compiler when --closure_pass
- * or --mark_as_compiled is specified.
- */
-var COMPILED = false;
-
-
-/**
- * Base namespace for the Closure library. Checks to see goog is
- * already defined in the current scope before assigning to prevent
- * clobbering if base.js is loaded more than once.
- *
- * @const
- */
-var goog = goog || {}; // Identifies this file as the Closure base.
-
-
-/**
- * Reference to the global context. In most cases this will be 'window'.
- */
-goog.global = this;
-
-
-/**
- * @define {boolean} DEBUG is provided as a convenience so that debugging code
- * that should not be included in a production js_binary can be easily stripped
- * by specifying --define goog.DEBUG=false to the JSCompiler. For example, most
- * toString() methods should be declared inside an "if (goog.DEBUG)" conditional
- * because they are generally used for debugging purposes and it is difficult
- * for the JSCompiler to statically determine whether they are used.
- */
-goog.DEBUG = true;
-
-
-/**
- * @define {string} LOCALE defines the locale being used for compilation. It is
- * used to select locale specific data to be compiled in js binary. BUILD rule
- * can specify this value by "--define goog.LOCALE=<locale_name>" as JSCompiler
- * option.
- *
- * Take into account that the locale code format is important. You should use
- * the canonical Unicode format with hyphen as a delimiter. Language must be
- * lowercase, Language Script - Capitalized, Region - UPPERCASE.
- * There are few examples: pt-BR, en, en-US, sr-Latin-BO, zh-Hans-CN.
- *
- * See more info about locale codes here:
- * http://www.unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers
- *
- * For language codes you should use values defined by ISO 693-1. See it here
- * http://www.w3.org/WAI/ER/IG/ert/iso639.htm. There is only one exception from
- * this rule: the Hebrew language. For legacy reasons the old code (iw) should
- * be used instead of the new code (he), see http://wiki/Main/IIISynonyms.
- */
-goog.LOCALE = 'en'; // default to en
-
-
-/**
- * Creates object stubs for a namespace. The presence of one or more
- * goog.provide() calls indicate that the file defines the given
- * objects/namespaces. Build tools also scan for provide/require statements
- * to discern dependencies, build dependency files (see deps.js), etc.
- * @see goog.require
- * @param {string} name Namespace provided by this file in the form
- * "goog.package.part".
- */
-goog.provide = function(name) {
- if (!COMPILED) {
- // Ensure that the same namespace isn't provided twice. This is intended
- // to teach new developers that 'goog.provide' is effectively a variable
- // declaration. And when JSCompiler transforms goog.provide into a real
- // variable declaration, the compiled JS should work the same as the raw
- // JS--even when the raw JS uses goog.provide incorrectly.
- if (goog.isProvided_(name)) {
- throw Error('Namespace "' + name + '" already declared.');
- }
- delete goog.implicitNamespaces_[name];
-
- var namespace = name;
- while ((namespace = namespace.substring(0, namespace.lastIndexOf('.')))) {
- if (goog.getObjectByName(namespace)) {
- break;
- }
- goog.implicitNamespaces_[namespace] = true;
- }
- }
-
- goog.exportPath_(name);
-};
-
-
-/**
- * Marks that the current file should only be used for testing, and never for
- * live code in production.
- * @param {string=} opt_message Optional message to add to the error that's
- * raised when used in production code.
- */
-goog.setTestOnly = function(opt_message) {
- if (COMPILED && !goog.DEBUG) {
- opt_message = opt_message || '';
- throw Error('Importing test-only code into non-debug environment' +
- opt_message ? ': ' + opt_message : '.');
- }
-};
-
-
-if (!COMPILED) {
-
- /**
- * Check if the given name has been goog.provided. This will return false for
- * names that are available only as implicit namespaces.
- * @param {string} name name of the object to look for.
- * @return {boolean} Whether the name has been provided.
- * @private
- */
- goog.isProvided_ = function(name) {
- return !goog.implicitNamespaces_[name] && !!goog.getObjectByName(name);
- };
-
- /**
- * Namespaces implicitly defined by goog.provide. For example,
- * goog.provide('goog.events.Event') implicitly declares
- * that 'goog' and 'goog.events' must be namespaces.
- *
- * @type {Object}
- * @private
- */
- goog.implicitNamespaces_ = {};
-}
-
-
-/**
- * Builds an object structure for the provided namespace path,
- * ensuring that names that already exist are not overwritten. For
- * example:
- * "a.b.c" -> a = {};a.b={};a.b.c={};
- * Used by goog.provide and goog.exportSymbol.
- * @param {string} name name of the object that this file defines.
- * @param {*=} opt_object the object to expose at the end of the path.
- * @param {Object=} opt_objectToExportTo The object to add the path to; default
- * is |goog.global|.
- * @private
- */
-goog.exportPath_ = function(name, opt_object, opt_objectToExportTo) {
- var parts = name.split('.');
- var cur = opt_objectToExportTo || goog.global;
-
- // Internet Explorer exhibits strange behavior when throwing errors from
- // methods externed in this manner. See the testExportSymbolExceptions in
- // base_test.html for an example.
- if (!(parts[0] in cur) && cur.execScript) {
- cur.execScript('var ' + parts[0]);
- }
-
- // Certain browsers cannot parse code in the form for((a in b); c;);
- // This pattern is produced by the JSCompiler when it collapses the
- // statement above into the conditional loop below. To prevent this from
- // happening, use a for-loop and reserve the init logic as below.
-
- // Parentheses added to eliminate strict JS warning in Firefox.
- for (var part; parts.length && (part = parts.shift());) {
- if (!parts.length && goog.isDef(opt_object)) {
- // last part and we have an object; use it
- cur[part] = opt_object;
- } else if (cur[part]) {
- cur = cur[part];
- } else {
- cur = cur[part] = {};
- }
- }
-};
-
-
-/**
- * Returns an object based on its fully qualified external name. If you are
- * using a compilation pass that renames property names beware that using this
- * function will not find renamed properties.
- *
- * @param {string} name The fully qualified name.
- * @param {Object=} opt_obj The object within which to look; default is
- * |goog.global|.
- * @return {?} The value (object or primitive) or, if not found, null.
- */
-goog.getObjectByName = function(name, opt_obj) {
- var parts = name.split('.');
- var cur = opt_obj || goog.global;
- for (var part; part = parts.shift(); ) {
- if (goog.isDefAndNotNull(cur[part])) {
- cur = cur[part];
- } else {
- return null;
- }
- }
- return cur;
-};
-
-
-/**
- * Globalizes a whole namespace, such as goog or goog.lang.
- *
- * @param {Object} obj The namespace to globalize.
- * @param {Object=} opt_global The object to add the properties to.
- * @deprecated Properties may be explicitly exported to the global scope, but
- * this should no longer be done in bulk.
- */
-goog.globalize = function(obj, opt_global) {
- var global = opt_global || goog.global;
- for (var x in obj) {
- global[x] = obj[x];
- }
-};
-
-
-/**
- * Adds a dependency from a file to the files it requires.
- * @param {string} relPath The path to the js file.
- * @param {Array} provides An array of strings with the names of the objects
- * this file provides.
- * @param {Array} requires An array of strings with the names of the objects
- * this file requires.
- */
-goog.addDependency = function(relPath, provides, requires) {
- if (!COMPILED) {
- var provide, require;
- var path = relPath.replace(/\\/g, '/');
- var deps = goog.dependencies_;
- for (var i = 0; provide = provides[i]; i++) {
- deps.nameToPath[provide] = path;
- if (!(path in deps.pathToNames)) {
- deps.pathToNames[path] = {};
- }
- deps.pathToNames[path][provide] = true;
- }
- for (var j = 0; require = requires[j]; j++) {
- if (!(path in deps.requires)) {
- deps.requires[path] = {};
- }
- deps.requires[path][require] = true;
- }
- }
-};
-
-
-
-
-// NOTE(nnaze): The debug DOM loader was included in base.js as an orignal
-// way to do "debug-mode" development. The dependency system can sometimes
-// be confusing, as can the debug DOM loader's asyncronous nature.
-//
-// With the DOM loader, a call to goog.require() is not blocking -- the
-// script will not load until some point after the current script. If a
-// namespace is needed at runtime, it needs to be defined in a previous
-// script, or loaded via require() with its registered dependencies.
-// User-defined namespaces may need their own deps file. See http://go/js_deps,
-// http://go/genjsdeps, or, externally, DepsWriter.
-// http://code.google.com/closure/library/docs/depswriter.html
-//
-// Because of legacy clients, the DOM loader can't be easily removed from
-// base.js. Work is being done to make it disableable or replaceable for
-// different environments (DOM-less JavaScript interpreters like Rhino or V8,
-// for example). See bootstrap/ for more information.
-
-
-/**
- * @define {boolean} Whether to enable the debug loader.
- *
- * If enabled, a call to goog.require() will attempt to load the namespace by
- * appending a script tag to the DOM (if the namespace has been registered).
- *
- * If disabled, goog.require() will simply assert that the namespace has been
- * provided (and depend on the fact that some outside tool correctly ordered
- * the script).
- */
-goog.ENABLE_DEBUG_LOADER = true;
-
-
-/**
- * Implements a system for the dynamic resolution of dependencies
- * that works in parallel with the BUILD system. Note that all calls
- * to goog.require will be stripped by the JSCompiler when the
- * --closure_pass option is used.
- * @see goog.provide
- * @param {string} name Namespace to include (as was given in goog.provide())
- * in the form "goog.package.part".
- */
-goog.require = function(name) {
-
- // if the object already exists we do not need do do anything
- // TODO(arv): If we start to support require based on file name this has
- // to change
- // TODO(arv): If we allow goog.foo.* this has to change
- // TODO(arv): If we implement dynamic load after page load we should probably
- // not remove this code for the compiled output
- if (!COMPILED) {
- if (goog.isProvided_(name)) {
- return;
- }
-
- if (goog.ENABLE_DEBUG_LOADER) {
- var path = goog.getPathFromDeps_(name);
- if (path) {
- goog.included_[path] = true;
- goog.writeScripts_();
- return;
- }
- }
-
- var errorMessage = 'goog.require could not find: ' + name;
- if (goog.global.console) {
- goog.global.console['error'](errorMessage);
- }
-
-
- throw Error(errorMessage);
-
- }
-};
-
-
-/**
- * Path for included scripts
- * @type {string}
- */
-goog.basePath = '';
-
-
-/**
- * A hook for overriding the base path.
- * @type {string|undefined}
- */
-goog.global.CLOSURE_BASE_PATH;
-
-
-/**
- * Whether to write out Closure's deps file. By default,
- * the deps are written.
- * @type {boolean|undefined}
- */
-goog.global.CLOSURE_NO_DEPS;
-
-
-/**
- * A function to import a single script. This is meant to be overridden when
- * Closure is being run in non-HTML contexts, such as web workers. It's defined
- * in the global scope so that it can be set before base.js is loaded, which
- * allows deps.js to be imported properly.
- *
- * The function is passed the script source, which is a relative URI. It should
- * return true if the script was imported, false otherwise.
- */
-goog.global.CLOSURE_IMPORT_SCRIPT;
-
-
-/**
- * Null function used for default values of callbacks, etc.
- * @return {void} Nothing.
- */
-goog.nullFunction = function() {};
-
-
-/**
- * The identity function. Returns its first argument.
- *
- * @param {*=} opt_returnValue The single value that will be returned.
- * @param {...*} var_args Optional trailing arguments. These are ignored.
- * @return {?} The first argument. We can't know the type -- just pass it along
- * without type.
- * @deprecated Use goog.functions.identity instead.
- */
-goog.identityFunction = function(opt_returnValue, var_args) {
- return opt_returnValue;
-};
-
-
-/**
- * When defining a class Foo with an abstract method bar(), you can do:
- *
- * Foo.prototype.bar = goog.abstractMethod
- *
- * Now if a subclass of Foo fails to override bar(), an error
- * will be thrown when bar() is invoked.
- *
- * Note: This does not take the name of the function to override as
- * an argument because that would make it more difficult to obfuscate
- * our JavaScript code.
- *
- * @type {!Function}
- * @throws {Error} when invoked to indicate the method should be
- * overridden.
- */
-goog.abstractMethod = function() {
- throw Error('unimplemented abstract method');
-};
-
-
-/**
- * Adds a {@code getInstance} static method that always return the same instance
- * object.
- * @param {!Function} ctor The constructor for the class to add the static
- * method to.
- */
-goog.addSingletonGetter = function(ctor) {
- ctor.getInstance = function() {
- if (ctor.instance_) {
- return ctor.instance_;
- }
- if (goog.DEBUG) {
- // NOTE: JSCompiler can't optimize away Array#push.
- goog.instantiatedSingletons_[goog.instantiatedSingletons_.length] = ctor;
- }
- return ctor.instance_ = new ctor;
- };
-};
-
-
-/**
- * All singleton classes that have been instantiated, for testing. Don't read
- * it directly, use the {@code goog.testing.singleton} module. The compiler
- * removes this variable if unused.
- * @type {!Array.<!Function>}
- * @private
- */
-goog.instantiatedSingletons_ = [];
-
-
-if (!COMPILED && goog.ENABLE_DEBUG_LOADER) {
- /**
- * Object used to keep track of urls that have already been added. This
- * record allows the prevention of circular dependencies.
- * @type {Object}
- * @private
- */
- goog.included_ = {};
-
-
- /**
- * This object is used to keep track of dependencies and other data that is
- * used for loading scripts
- * @private
- * @type {Object}
- */
- goog.dependencies_ = {
- pathToNames: {}, // 1 to many
- nameToPath: {}, // 1 to 1
- requires: {}, // 1 to many
- // used when resolving dependencies to prevent us from
- // visiting the file twice
- visited: {},
- written: {} // used to keep track of script files we have written
- };
-
-
- /**
- * Tries to detect whether is in the context of an HTML document.
- * @return {boolean} True if it looks like HTML document.
- * @private
- */
- goog.inHtmlDocument_ = function() {
- var doc = goog.global.document;
- return typeof doc != 'undefined' &&
- 'write' in doc; // XULDocument misses write.
- };
-
-
- /**
- * Tries to detect the base path of the base.js script that bootstraps Closure
- * @private
- */
- goog.findBasePath_ = function() {
- if (goog.global.CLOSURE_BASE_PATH) {
- goog.basePath = goog.global.CLOSURE_BASE_PATH;
- return;
- } else if (!goog.inHtmlDocument_()) {
- return;
- }
- var doc = goog.global.document;
- var scripts = doc.getElementsByTagName('script');
- // Search backwards since the current script is in almost all cases the one
- // that has base.js.
- for (var i = scripts.length - 1; i >= 0; --i) {
- var src = scripts[i].src;
- var qmark = src.lastIndexOf('?');
- var l = qmark == -1 ? src.length : qmark;
- if (src.substr(l - 7, 7) == 'base.js') {
- goog.basePath = src.substr(0, l - 7);
- return;
- }
- }
- };
-
-
- /**
- * Imports a script if, and only if, that script hasn't already been imported.
- * (Must be called at execution time)
- * @param {string} src Script source.
- * @private
- */
- goog.importScript_ = function(src) {
- var importScript = goog.global.CLOSURE_IMPORT_SCRIPT ||
- goog.writeScriptTag_;
- if (!goog.dependencies_.written[src] && importScript(src)) {
- goog.dependencies_.written[src] = true;
- }
- };
-
-
- /**
- * The default implementation of the import function. Writes a script tag to
- * import the script.
- *
- * @param {string} src The script source.
- * @return {boolean} True if the script was imported, false otherwise.
- * @private
- */
- goog.writeScriptTag_ = function(src) {
- if (goog.inHtmlDocument_()) {
- var doc = goog.global.document;
- doc.write(
- '<script type="text/javascript" src="' + src + '"></' + 'script>');
- return true;
- } else {
- return false;
- }
- };
-
-
- /**
- * Resolves dependencies based on the dependencies added using addDependency
- * and calls importScript_ in the correct order.
- * @private
- */
- goog.writeScripts_ = function() {
- // the scripts we need to write this time
- var scripts = [];
- var seenScript = {};
- var deps = goog.dependencies_;
-
- function visitNode(path) {
- if (path in deps.written) {
- return;
- }
-
- // we have already visited this one. We can get here if we have cyclic
- // dependencies
- if (path in deps.visited) {
- if (!(path in seenScript)) {
- seenScript[path] = true;
- scripts.push(path);
- }
- return;
- }
-
- deps.visited[path] = true;
-
- if (path in deps.requires) {
- for (var requireName in deps.requires[path]) {
- // If the required name is defined, we assume that it was already
- // bootstrapped by other means.
- if (!goog.isProvided_(requireName)) {
- if (requireName in deps.nameToPath) {
- visitNode(deps.nameToPath[requireName]);
- } else {
- throw Error('Undefined nameToPath for ' + requireName);
- }
- }
- }
- }
-
- if (!(path in seenScript)) {
- seenScript[path] = true;
- scripts.push(path);
- }
- }
-
- for (var path in goog.included_) {
- if (!deps.written[path]) {
- visitNode(path);
- }
- }
-
- for (var i = 0; i < scripts.length; i++) {
- if (scripts[i]) {
- goog.importScript_(goog.basePath + scripts[i]);
- } else {
- throw Error('Undefined script input');
- }
- }
- };
-
-
- /**
- * Looks at the dependency rules and tries to determine the script file that
- * fulfills a particular rule.
- * @param {string} rule In the form goog.namespace.Class or project.script.
- * @return {?string} Url corresponding to the rule, or null.
- * @private
- */
- goog.getPathFromDeps_ = function(rule) {
- if (rule in goog.dependencies_.nameToPath) {
- return goog.dependencies_.nameToPath[rule];
- } else {
- return null;
- }
- };
-
- goog.findBasePath_();
-
- // Allow projects to manage the deps files themselves.
- if (!goog.global.CLOSURE_NO_DEPS) {
- goog.importScript_(goog.basePath + 'deps.js');
- }
-}
-
-
-
-//==============================================================================
-// Language Enhancements
-//==============================================================================
-
-
-/**
- * This is a "fixed" version of the typeof operator. It differs from the typeof
- * operator in such a way that null returns 'null' and arrays return 'array'.
- * @param {*} value The value to get the type of.
- * @return {string} The name of the type.
- */
-goog.typeOf = function(value) {
- var s = typeof value;
- if (s == 'object') {
- if (value) {
- // Check these first, so we can avoid calling Object.prototype.toString if
- // possible.
- //
- // IE improperly marshals tyepof across execution contexts, but a
- // cross-context object will still return false for "instanceof Object".
- if (value instanceof Array) {
- return 'array';
- } else if (value instanceof Object) {
- return s;
- }
-
- // HACK: In order to use an Object prototype method on the arbitrary
- // value, the compiler requires the value be cast to type Object,
- // even though the ECMA spec explicitly allows it.
- var className = Object.prototype.toString.call(
- /** @type {Object} */ (value));
- // In Firefox 3.6, attempting to access iframe window objects' length
- // property throws an NS_ERROR_FAILURE, so we need to special-case it
- // here.
- if (className == '[object Window]') {
- return 'object';
- }
-
- // We cannot always use constructor == Array or instanceof Array because
- // different frames have different Array objects. In IE6, if the iframe
- // where the array was created is destroyed, the array loses its
- // prototype. Then dereferencing val.splice here throws an exception, so
- // we can't use goog.isFunction. Calling typeof directly returns 'unknown'
- // so that will work. In this case, this function will return false and
- // most array functions will still work because the array is still
- // array-like (supports length and []) even though it has lost its
- // prototype.
- // Mark Miller noticed that Object.prototype.toString
- // allows access to the unforgeable [[Class]] property.
- // 15.2.4.2 Object.prototype.toString ( )
- // When the toString method is called, the following steps are taken:
- // 1. Get the [[Class]] property of this object.
- // 2. Compute a string value by concatenating the three strings
- // "[object ", Result(1), and "]".
- // 3. Return Result(2).
- // and this behavior survives the destruction of the execution context.
- if ((className == '[object Array]' ||
- // In IE all non value types are wrapped as objects across window
- // boundaries (not iframe though) so we have to do object detection
- // for this edge case
- typeof value.length == 'number' &&
- typeof value.splice != 'undefined' &&
- typeof value.propertyIsEnumerable != 'undefined' &&
- !value.propertyIsEnumerable('splice')
-
- )) {
- return 'array';
- }
- // HACK: There is still an array case that fails.
- // function ArrayImpostor() {}
- // ArrayImpostor.prototype = [];
- // var impostor = new ArrayImpostor;
- // this can be fixed by getting rid of the fast path
- // (value instanceof Array) and solely relying on
- // (value && Object.prototype.toString.vall(value) === '[object Array]')
- // but that would require many more function calls and is not warranted
- // unless closure code is receiving objects from untrusted sources.
-
- // IE in cross-window calls does not correctly marshal the function type
- // (it appears just as an object) so we cannot use just typeof val ==
- // 'function'. However, if the object has a call property, it is a
- // function.
- if ((className == '[object Function]' ||
- typeof value.call != 'undefined' &&
- typeof value.propertyIsEnumerable != 'undefined' &&
- !value.propertyIsEnumerable('call'))) {
- return 'function';
- }
-
-
- } else {
- return 'null';
- }
-
- } else if (s == 'function' && typeof value.call == 'undefined') {
- // In Safari typeof nodeList returns 'function', and on Firefox
- // typeof behaves similarly for HTML{Applet,Embed,Object}Elements
- // and RegExps. We would like to return object for those and we can
- // detect an invalid function by making sure that the function
- // object has a call method.
- return 'object';
- }
- return s;
-};
-
-
-/**
- * Returns true if the specified value is not |undefined|.
- * WARNING: Do not use this to test if an object has a property. Use the in
- * operator instead. Additionally, this function assumes that the global
- * undefined variable has not been redefined.
- * @param {*} val Variable to test.
- * @return {boolean} Whether variable is defined.
- */
-goog.isDef = function(val) {
- return val !== undefined;
-};
-
-
-/**
- * Returns true if the specified value is |null|
- * @param {*} val Variable to test.
- * @return {boolean} Whether variable is null.
- */
-goog.isNull = function(val) {
- return val === null;
-};
-
-
-/**
- * Returns true if the specified value is defined and not null
- * @param {*} val Variable to test.
- * @return {boolean} Whether variable is defined and not null.
- */
-goog.isDefAndNotNull = function(val) {
- // Note that undefined == null.
- return val != null;
-};
-
-
-/**
- * Returns true if the specified value is an array
- * @param {*} val Variable to test.
- * @return {boolean} Whether variable is an array.
- */
-goog.isArray = function(val) {
- return goog.typeOf(val) == 'array';
-};
-
-
-/**
- * Returns true if the object looks like an array. To qualify as array like
- * the value needs to be either a NodeList or an object with a Number length
- * property.
- * @param {*} val Variable to test.
- * @return {boolean} Whether variable is an array.
- */
-goog.isArrayLike = function(val) {
- var type = goog.typeOf(val);
- return type == 'array' || type == 'object' && typeof val.length == 'number';
-};
-
-
-/**
- * Returns true if the object looks like a Date. To qualify as Date-like
- * the value needs to be an object and have a getFullYear() function.
- * @param {*} val Variable to test.
- * @return {boolean} Whether variable is a like a Date.
- */
-goog.isDateLike = function(val) {
- return goog.isObject(val) && typeof val.getFullYear == 'function';
-};
-
-
-/**
- * Returns true if the specified value is a string
- * @param {*} val Variable to test.
- * @return {boolean} Whether variable is a string.
- */
-goog.isString = function(val) {
- return typeof val == 'string';
-};
-
-
-/**
- * Returns true if the specified value is a boolean
- * @param {*} val Variable to test.
- * @return {boolean} Whether variable is boolean.
- */
-goog.isBoolean = function(val) {
- return typeof val == 'boolean';
-};
-
-
-/**
- * Returns true if the specified value is a number
- * @param {*} val Variable to test.
- * @return {boolean} Whether variable is a number.
- */
-goog.isNumber = function(val) {
- return typeof val == 'number';
-};
-
-
-/**
- * Returns true if the specified value is a function
- * @param {*} val Variable to test.
- * @return {boolean} Whether variable is a function.
- */
-goog.isFunction = function(val) {
- return goog.typeOf(val) == 'function';
-};
-
-
-/**
- * Returns true if the specified value is an object. This includes arrays
- * and functions.
- * @param {*} val Variable to test.
- * @return {boolean} Whether variable is an object.
- */
-goog.isObject = function(val) {
- var type = typeof val;
- return type == 'object' && val != null || type == 'function';
- // return Object(val) === val also works, but is slower, especially if val is
- // not an object.
-};
-
-
-/**
- * Gets a unique ID for an object. This mutates the object so that further
- * calls with the same object as a parameter returns the same value. The unique
- * ID is guaranteed to be unique across the current session amongst objects that
- * are passed into {@code getUid}. There is no guarantee that the ID is unique
- * or consistent across sessions. It is unsafe to generate unique ID for
- * function prototypes.
- *
- * @param {Object} obj The object to get the unique ID for.
- * @return {number} The unique ID for the object.
- */
-goog.getUid = function(obj) {
- // TODO(arv): Make the type stricter, do not accept null.
-
- // In Opera window.hasOwnProperty exists but always returns false so we avoid
- // using it. As a consequence the unique ID generated for BaseClass.prototype
- // and SubClass.prototype will be the same.
- return obj[goog.UID_PROPERTY_] ||
- (obj[goog.UID_PROPERTY_] = ++goog.uidCounter_);
-};
-
-
-/**
- * Removes the unique ID from an object. This is useful if the object was
- * previously mutated using {@code goog.getUid} in which case the mutation is
- * undone.
- * @param {Object} obj The object to remove the unique ID field from.
- */
-goog.removeUid = function(obj) {
- // TODO(arv): Make the type stricter, do not accept null.
-
- // DOM nodes in IE are not instance of Object and throws exception
- // for delete. Instead we try to use removeAttribute
- if ('removeAttribute' in obj) {
- obj.removeAttribute(goog.UID_PROPERTY_);
- }
- /** @preserveTry */
- try {
- delete obj[goog.UID_PROPERTY_];
- } catch (ex) {
- }
-};
-
-
-/**
- * Name for unique ID property. Initialized in a way to help avoid collisions
- * with other closure javascript on the same page.
- * @type {string}
- * @private
- */
-goog.UID_PROPERTY_ = 'closure_uid_' +
- Math.floor(Math.random() * 2147483648).toString(36);
-
-
-/**
- * Counter for UID.
- * @type {number}
- * @private
- */
-goog.uidCounter_ = 0;
-
-
-/**
- * Adds a hash code field to an object. The hash code is unique for the
- * given object.
- * @param {Object} obj The object to get the hash code for.
- * @return {number} The hash code for the object.
- * @deprecated Use goog.getUid instead.
- */
-goog.getHashCode = goog.getUid;
-
-
-/**
- * Removes the hash code field from an object.
- * @param {Object} obj The object to remove the field from.
- * @deprecated Use goog.removeUid instead.
- */
-goog.removeHashCode = goog.removeUid;
-
-
-/**
- * Clones a value. The input may be an Object, Array, or basic type. Objects and
- * arrays will be cloned recursively.
- *
- * WARNINGS:
- * <code>goog.cloneObject</code> does not detect reference loops. Objects that
- * refer to themselves will cause infinite recursion.
- *
- * <code>goog.cloneObject</code> is unaware of unique identifiers, and copies
- * UIDs created by <code>getUid</code> into cloned results.
- *
- * @param {*} obj The value to clone.
- * @return {*} A clone of the input value.
- * @deprecated goog.cloneObject is unsafe. Prefer the goog.object methods.
- */
-goog.cloneObject = function(obj) {
- var type = goog.typeOf(obj);
- if (type == 'object' || type == 'array') {
- if (obj.clone) {
- return obj.clone();
- }
- var clone = type == 'array' ? [] : {};
- for (var key in obj) {
- clone[key] = goog.cloneObject(obj[key]);
- }
- return clone;
- }
-
- return obj;
-};
-
-
-/**
- * Forward declaration for the clone method. This is necessary until the
- * compiler can better support duck-typing constructs as used in
- * goog.cloneObject.
- *
- * TODO(brenneman): Remove once the JSCompiler can infer that the check for
- * proto.clone is safe in goog.cloneObject.
- *
- * @type {Function}
- */
-Object.prototype.clone;
-
-
-/**
- * A native implementation of goog.bind.
- * @param {Function} fn A function to partially apply.
- * @param {Object|undefined} selfObj Specifies the object which |this| should
- * point to when the function is run.
- * @param {...*} var_args Additional arguments that are partially
- * applied to the function.
- * @return {!Function} A partially-applied form of the function bind() was
- * invoked as a method of.
- * @private
- * @suppress {deprecated} The compiler thinks that Function.prototype.bind
- * is deprecated because some people have declared a pure-JS version.
- * Only the pure-JS version is truly deprecated.
- */
-goog.bindNative_ = function(fn, selfObj, var_args) {
- return /** @type {!Function} */ (fn.call.apply(fn.bind, arguments));
-};
-
-
-/**
- * A pure-JS implementation of goog.bind.
- * @param {Function} fn A function to partially apply.
- * @param {Object|undefined} selfObj Specifies the object which |this| should
- * point to when the function is run.
- * @param {...*} var_args Additional arguments that are partially
- * applied to the function.
- * @return {!Function} A partially-applied form of the function bind() was
- * invoked as a method of.
- * @private
- */
-goog.bindJs_ = function(fn, selfObj, var_args) {
- if (!fn) {
- throw new Error();
- }
-
- if (arguments.length > 2) {
- var boundArgs = Array.prototype.slice.call(arguments, 2);
- return function() {
- // Prepend the bound arguments to the current arguments.
- var newArgs = Array.prototype.slice.call(arguments);
- Array.prototype.unshift.apply(newArgs, boundArgs);
- return fn.apply(selfObj, newArgs);
- };
-
- } else {
- return function() {
- return fn.apply(selfObj, arguments);
- };
- }
-};
-
-
-/**
- * Partially applies this function to a particular 'this object' and zero or
- * more arguments. The result is a new function with some arguments of the first
- * function pre-filled and the value of |this| 'pre-specified'.<br><br>
- *
- * Remaining arguments specified at call-time are appended to the pre-
- * specified ones.<br><br>
- *
- * Also see: {@link #partial}.<br><br>
- *
- * Usage:
- * <pre>var barMethBound = bind(myFunction, myObj, 'arg1', 'arg2');
- * barMethBound('arg3', 'arg4');</pre>
- *
- * @param {Function} fn A function to partially apply.
- * @param {Object|undefined} selfObj Specifies the object which |this| should
- * point to when the function is run.
- * @param {...*} var_args Additional arguments that are partially
- * applied to the function.
- * @return {!Function} A partially-applied form of the function bind() was
- * invoked as a method of.
- * @suppress {deprecated} See above.
- */
-goog.bind = function(fn, selfObj, var_args) {
- // TODO(nicksantos): narrow the type signature.
- if (Function.prototype.bind &&
- // NOTE(nicksantos): Somebody pulled base.js into the default
- // Chrome extension environment. This means that for Chrome extensions,
- // they get the implementation of Function.prototype.bind that
- // calls goog.bind instead of the native one. Even worse, we don't want
- // to introduce a circular dependency between goog.bind and
- // Function.prototype.bind, so we have to hack this to make sure it
- // works correctly.
- Function.prototype.bind.toString().indexOf('native code') != -1) {
- goog.bind = goog.bindNative_;
- } else {
- goog.bind = goog.bindJs_;
- }
- return goog.bind.apply(null, arguments);
-};
-
-
-/**
- * Like bind(), except that a 'this object' is not required. Useful when the
- * target function is already bound.
- *
- * Usage:
- * var g = partial(f, arg1, arg2);
- * g(arg3, arg4);
- *
- * @param {Function} fn A function to partially apply.
- * @param {...*} var_args Additional arguments that are partially
- * applied to fn.
- * @return {!Function} A partially-applied form of the function bind() was
- * invoked as a method of.
- */
-goog.partial = function(fn, var_args) {
- var args = Array.prototype.slice.call(arguments, 1);
- return function() {
- // Prepend the bound arguments to the current arguments.
- var newArgs = Array.prototype.slice.call(arguments);
- newArgs.unshift.apply(newArgs, args);
- return fn.apply(this, newArgs);
- };
-};
-
-
-/**
- * Copies all the members of a source object to a target object. This method
- * does not work on all browsers for all objects that contain keys such as
- * toString or hasOwnProperty. Use goog.object.extend for this purpose.
- * @param {Object} target Target.
- * @param {Object} source Source.
- */
-goog.mixin = function(target, source) {
- for (var x in source) {
- target[x] = source[x];
- }
-
- // For IE7 or lower, the for-in-loop does not contain any properties that are
- // not enumerable on the prototype object (for example, isPrototypeOf from
- // Object.prototype) but also it will not include 'replace' on objects that
- // extend String and change 'replace' (not that it is common for anyone to
- // extend anything except Object).
-};
-
-
-/**
- * @return {number} An integer value representing the number of milliseconds
- * between midnight, January 1, 1970 and the current time.
- */
-goog.now = Date.now || (function() {
- // Unary plus operator converts its operand to a number which in the case of
- // a date is done by calling getTime().
- return +new Date();
-});
-
-
-/**
- * Evals javascript in the global scope. In IE this uses execScript, other
- * browsers use goog.global.eval. If goog.global.eval does not evaluate in the
- * global scope (for example, in Safari), appends a script tag instead.
- * Throws an exception if neither execScript or eval is defined.
- * @param {string} script JavaScript string.
- */
-goog.globalEval = function(script) {
- if (goog.global.execScript) {
- goog.global.execScript(script, 'JavaScript');
- } else if (goog.global.eval) {
- // Test to see if eval works
- if (goog.evalWorksForGlobals_ == null) {
- goog.global.eval('var _et_ = 1;');
- if (typeof goog.global['_et_'] != 'undefined') {
- delete goog.global['_et_'];
- goog.evalWorksForGlobals_ = true;
- } else {
- goog.evalWorksForGlobals_ = false;
- }
- }
-
- if (goog.evalWorksForGlobals_) {
- goog.global.eval(script);
- } else {
- var doc = goog.global.document;
- var scriptElt = doc.createElement('script');
- scriptElt.type = 'text/javascript';
- scriptElt.defer = false;
- // Note(user): can't use .innerHTML since "t('<test>')" will fail and
- // .text doesn't work in Safari 2. Therefore we append a text node.
- scriptElt.appendChild(doc.createTextNode(script));
- doc.body.appendChild(scriptElt);
- doc.body.removeChild(scriptElt);
- }
- } else {
- throw Error('goog.globalEval not available');
- }
-};
-
-
-/**
- * Indicates whether or not we can call 'eval' directly to eval code in the
- * global scope. Set to a Boolean by the first call to goog.globalEval (which
- * empirically tests whether eval works for globals). @see goog.globalEval
- * @type {?boolean}
- * @private
- */
-goog.evalWorksForGlobals_ = null;
-
-
-/**
- * Optional map of CSS class names to obfuscated names used with
- * goog.getCssName().
- * @type {Object|undefined}
- * @private
- * @see goog.setCssNameMapping
- */
-goog.cssNameMapping_;
-
-
-/**
- * Optional obfuscation style for CSS class names. Should be set to either
- * 'BY_WHOLE' or 'BY_PART' if defined.
- * @type {string|undefined}
- * @private
- * @see goog.setCssNameMapping
- */
-goog.cssNameMappingStyle_;
-
-
-/**
- * Handles strings that are intended to be used as CSS class names.
- *
- * This function works in tandem with @see goog.setCssNameMapping.
- *
- * Without any mapping set, the arguments are simple joined with a
- * hyphen and passed through unaltered.
- *
- * When there is a mapping, there are two possible styles in which
- * these mappings are used. In the BY_PART style, each part (i.e. in
- * between hyphens) of the passed in css name is rewritten according
- * to the map. In the BY_WHOLE style, the full css name is looked up in
- * the map directly. If a rewrite is not specified by the map, the
- * compiler will output a warning.
- *
- * When the mapping is passed to the compiler, it will replace calls
- * to goog.getCssName with the strings from the mapping, e.g.
- * var x = goog.getCssName('foo');
- * var y = goog.getCssName(this.baseClass, 'active');
- * becomes:
- * var x= 'foo';
- * var y = this.baseClass + '-active';
- *
- * If one argument is passed it will be processed, if two are passed
- * only the modifier will be processed, as it is assumed the first
- * argument was generated as a result of calling goog.getCssName.
- *
- * @param {string} className The class name.
- * @param {string=} opt_modifier A modifier to be appended to the class name.
- * @return {string} The class name or the concatenation of the class name and
- * the modifier.
- */
-goog.getCssName = function(className, opt_modifier) {
- var getMapping = function(cssName) {
- return goog.cssNameMapping_[cssName] || cssName;
- };
-
- var renameByParts = function(cssName) {
- // Remap all the parts individually.
- var parts = cssName.split('-');
- var mapped = [];
- for (var i = 0; i < parts.length; i++) {
- mapped.push(getMapping(parts[i]));
- }
- return mapped.join('-');
- };
-
- var rename;
- if (goog.cssNameMapping_) {
- rename = goog.cssNameMappingStyle_ == 'BY_WHOLE' ?
- getMapping : renameByParts;
- } else {
- rename = function(a) {
- return a;
- };
- }
-
- if (opt_modifier) {
- return className + '-' + rename(opt_modifier);
- } else {
- return rename(className);
- }
-};
-
-
-/**
- * Sets the map to check when returning a value from goog.getCssName(). Example:
- * <pre>
- * goog.setCssNameMapping({
- * "goog": "a",
- * "disabled": "b",
- * });
- *
- * var x = goog.getCssName('goog');
- * // The following evaluates to: "a a-b".
- * goog.getCssName('goog') + ' ' + goog.getCssName(x, 'disabled')
- * </pre>
- * When declared as a map of string literals to string literals, the JSCompiler
- * will replace all calls to goog.getCssName() using the supplied map if the
- * --closure_pass flag is set.
- *
- * @param {!Object} mapping A map of strings to strings where keys are possible
- * arguments to goog.getCssName() and values are the corresponding values
- * that should be returned.
- * @param {string=} opt_style The style of css name mapping. There are two valid
- * options: 'BY_PART', and 'BY_WHOLE'.
- * @see goog.getCssName for a description.
- */
-goog.setCssNameMapping = function(mapping, opt_style) {
- goog.cssNameMapping_ = mapping;
- goog.cssNameMappingStyle_ = opt_style;
-};
-
-
-/**
- * To use CSS renaming in compiled mode, one of the input files should have a
- * call to goog.setCssNameMapping() with an object literal that the JSCompiler
- * can extract and use to replace all calls to goog.getCssName(). In uncompiled
- * mode, JavaScript code should be loaded before this base.js file that declares
- * a global variable, CLOSURE_CSS_NAME_MAPPING, which is used below. This is
- * to ensure that the mapping is loaded before any calls to goog.getCssName()
- * are made in uncompiled mode.
- *
- * A hook for overriding the CSS name mapping.
- * @type {Object|undefined}
- */
-goog.global.CLOSURE_CSS_NAME_MAPPING;
-
-
-if (!COMPILED && goog.global.CLOSURE_CSS_NAME_MAPPING) {
- // This does not call goog.setCssNameMapping() because the JSCompiler
- // requires that goog.setCssNameMapping() be called with an object literal.
- goog.cssNameMapping_ = goog.global.CLOSURE_CSS_NAME_MAPPING;
-}
-
-
-/**
- * Abstract implementation of goog.getMsg for use with localized messages.
- * @param {string} str Translatable string, places holders in the form {$foo}.
- * @param {Object=} opt_values Map of place holder name to value.
- * @return {string} message with placeholders filled.
- */
-goog.getMsg = function(str, opt_values) {
- var values = opt_values || {};
- for (var key in values) {
- var value = ('' + values[key]).replace(/\$/g, '$$$$');
- str = str.replace(new RegExp('\\{\\$' + key + '\\}', 'gi'), value);
- }
- return str;
-};
-
-
-/**
- * Exposes an unobfuscated global namespace path for the given object.
- * Note that fields of the exported object *will* be obfuscated,
- * unless they are exported in turn via this function or
- * goog.exportProperty
- *
- * <p>Also handy for making public items that are defined in anonymous
- * closures.
- *
- * ex. goog.exportSymbol('public.path.Foo', Foo);
- *
- * ex. goog.exportSymbol('public.path.Foo.staticFunction',
- * Foo.staticFunction);
- * public.path.Foo.staticFunction();
- *
- * ex. goog.exportSymbol('public.path.Foo.prototype.myMethod',
- * Foo.prototype.myMethod);
- * new public.path.Foo().myMethod();
- *
- * @param {string} publicPath Unobfuscated name to export.
- * @param {*} object Object the name should point to.
- * @param {Object=} opt_objectToExportTo The object to add the path to; default
- * is |goog.global|.
- */
-goog.exportSymbol = function(publicPath, object, opt_objectToExportTo) {
- goog.exportPath_(publicPath, object, opt_objectToExportTo);
-};
-
-
-/**
- * Exports a property unobfuscated into the object's namespace.
- * ex. goog.exportProperty(Foo, 'staticFunction', Foo.staticFunction);
- * ex. goog.exportProperty(Foo.prototype, 'myMethod', Foo.prototype.myMethod);
- * @param {Object} object Object whose static property is being exported.
- * @param {string} publicName Unobfuscated name to export.
- * @param {*} symbol Object the name should point to.
- */
-goog.exportProperty = function(object, publicName, symbol) {
- object[publicName] = symbol;
-};
-
-
-/**
- * Inherit the prototype methods from one constructor into another.
- *
- * Usage:
- * <pre>
- * function ParentClass(a, b) { }
- * ParentClass.prototype.foo = function(a) { }
- *
- * function ChildClass(a, b, c) {
- * goog.base(this, a, b);
- * }
- * goog.inherits(ChildClass, ParentClass);
- *
- * var child = new ChildClass('a', 'b', 'see');
- * child.foo(); // works
- * </pre>
- *
- * In addition, a superclass' implementation of a method can be invoked
- * as follows:
- *
- * <pre>
- * ChildClass.prototype.foo = function(a) {
- * ChildClass.superClass_.foo.call(this, a);
- * // other code
- * };
- * </pre>
- *
- * @param {Function} childCtor Child class.
- * @param {Function} parentCtor Parent class.
- */
-goog.inherits = function(childCtor, parentCtor) {
- /** @constructor */
- function tempCtor() {};
- tempCtor.prototype = parentCtor.prototype;
- childCtor.superClass_ = parentCtor.prototype;
- childCtor.prototype = new tempCtor();
- childCtor.prototype.constructor = childCtor;
-};
-
-
-/**
- * Call up to the superclass.
- *
- * If this is called from a constructor, then this calls the superclass
- * contructor with arguments 1-N.
- *
- * If this is called from a prototype method, then you must pass
- * the name of the method as the second argument to this function. If
- * you do not, you will get a runtime error. This calls the superclass'
- * method with arguments 2-N.
- *
- * This function only works if you use goog.inherits to express
- * inheritance relationships between your classes.
- *
- * This function is a compiler primitive. At compile-time, the
- * compiler will do macro expansion to remove a lot of
- * the extra overhead that this function introduces. The compiler
- * will also enforce a lot of the assumptions that this function
- * makes, and treat it as a compiler error if you break them.
- *
- * @param {!Object} me Should always be "this".
- * @param {*=} opt_methodName The method name if calling a super method.
- * @param {...*} var_args The rest of the arguments.
- * @return {*} The return value of the superclass method.
- */
-goog.base = function(me, opt_methodName, var_args) {
- var caller = arguments.callee.caller;
- if (caller.superClass_) {
- // This is a constructor. Call the superclass constructor.
- return caller.superClass_.constructor.apply(
- me, Array.prototype.slice.call(arguments, 1));
- }
-
- var args = Array.prototype.slice.call(arguments, 2);
- var foundCaller = false;
- for (var ctor = me.constructor;
- ctor; ctor = ctor.superClass_ && ctor.superClass_.constructor) {
- if (ctor.prototype[opt_methodName] === caller) {
- foundCaller = true;
- } else if (foundCaller) {
- return ctor.prototype[opt_methodName].apply(me, args);
- }
- }
-
- // If we did not find the caller in the prototype chain,
- // then one of two things happened:
- // 1) The caller is an instance method.
- // 2) This method was not called by the right caller.
- if (me[opt_methodName] === caller) {
- return me.constructor.prototype[opt_methodName].apply(me, args);
- } else {
- throw Error(
- 'goog.base called from a method of one name ' +
- 'to a method of a different name');
- }
-};
-
-
-/**
- * Allow for aliasing within scope functions. This function exists for
- * uncompiled code - in compiled code the calls will be inlined and the
- * aliases applied. In uncompiled code the function is simply run since the
- * aliases as written are valid JavaScript.
- * @param {function()} fn Function to call. This function can contain aliases
- * to namespaces (e.g. "var dom = goog.dom") or classes
- * (e.g. "var Timer = goog.Timer").
- */
-goog.scope = function(fn) {
- fn.call(goog.global);
-};
-
-
+++ /dev/null
-#!/usr/bin/env python
-#
-# Copyright 2009 The Closure Library Authors. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS-IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-"""Generates out a Closure deps.js file given a list of JavaScript sources.
-
-Paths can be specified as arguments or (more commonly) specifying trees
-with the flags (call with --help for descriptions).
-
-Usage: depswriter.py [path/to/js1.js [path/to/js2.js] ...]
-"""
-
-import logging
-import optparse
-import os
-import posixpath
-import shlex
-import sys
-
-import source
-import treescan
-
-
-__author__ = 'nnaze@google.com (Nathan Naze)'
-
-
-def MakeDepsFile(source_map):
- """Make a generated deps file.
-
- Args:
- source_map: A dict map of the source path to source.Source object.
-
- Returns:
- str, A generated deps file source.
- """
-
- # Write in path alphabetical order
- paths = sorted(source_map.keys())
-
- lines = []
-
- for path in paths:
- js_source = source_map[path]
-
- # We don't need to add entries that don't provide anything.
- if js_source.provides:
- lines.append(_GetDepsLine(path, js_source))
-
- return ''.join(lines)
-
-
-def _GetDepsLine(path, js_source):
- """Get a deps.js file string for a source."""
-
- provides = sorted(js_source.provides)
- requires = sorted(js_source.requires)
-
- return 'goog.addDependency(\'%s\', %s, %s);\n' % (path, provides, requires)
-
-
-def _GetOptionsParser():
- """Get the options parser."""
-
- parser = optparse.OptionParser(__doc__)
-
- parser.add_option('--output_file',
- dest='output_file',
- action='store',
- help=('If specified, write output to this path instead of '
- 'writing to standard output.'))
- parser.add_option('--root',
- dest='roots',
- default=[],
- action='append',
- help='A root directory to scan for JS source files. '
- 'Paths of JS files in generated deps file will be '
- 'relative to this path. This flag may be specified '
- 'multiple times.')
- parser.add_option('--root_with_prefix',
- dest='roots_with_prefix',
- default=[],
- action='append',
- help='A root directory to scan for JS source files, plus '
- 'a prefix (if either contains a space, surround with '
- 'quotes). Paths in generated deps file will be relative '
- 'to the root, but preceded by the prefix. This flag '
- 'may be specified multiple times.')
- parser.add_option('--path_with_depspath',
- dest='paths_with_depspath',
- default=[],
- action='append',
- help='A path to a source file and an alternate path to '
- 'the file in the generated deps file (if either contains '
- 'a space, surround with whitespace). This flag may be '
- 'specified multiple times.')
- return parser
-
-
-def _NormalizePathSeparators(path):
- """Replaces OS-specific path separators with POSIX-style slashes.
-
- Args:
- path: str, A file path.
-
- Returns:
- str, The path with any OS-specific path separators (such as backslash on
- Windows) replaced with URL-compatible forward slashes. A no-op on systems
- that use POSIX paths.
- """
- return path.replace(os.sep, posixpath.sep)
-
-
-def _GetRelativePathToSourceDict(root, prefix=''):
- """Scans a top root directory for .js sources.
-
- Args:
- root: str, Root directory.
- prefix: str, Prefix for returned paths.
-
- Returns:
- dict, A map of relative paths (with prefix, if given), to source.Source
- objects.
- """
- # Remember and restore the cwd when we're done. We work from the root so
- # that paths are relative from the root.
- start_wd = os.getcwd()
- os.chdir(root)
-
- path_to_source = {}
- for path in treescan.ScanTreeForJsFiles('.'):
- prefixed_path = _NormalizePathSeparators(os.path.join(prefix, path))
- path_to_source[prefixed_path] = source.Source(source.GetFileContents(path))
-
- os.chdir(start_wd)
-
- return path_to_source
-
-
-def _GetPair(s):
- """Return a string as a shell-parsed tuple. Two values expected."""
- try:
- # shlex uses '\' as an escape character, so they must be escaped.
- s = s.replace('\\', '\\\\')
- first, second = shlex.split(s)
- return (first, second)
- except:
- raise Exception('Unable to parse input line as a pair: %s' % s)
-
-
-def main():
- """CLI frontend to MakeDepsFile."""
- logging.basicConfig(format=(sys.argv[0] + ': %(message)s'),
- level=logging.INFO)
- options, args = _GetOptionsParser().parse_args()
-
- path_to_source = {}
-
- # Roots without prefixes
- for root in options.roots:
- path_to_source.update(_GetRelativePathToSourceDict(root))
-
- # Roots with prefixes
- for root_and_prefix in options.roots_with_prefix:
- root, prefix = _GetPair(root_and_prefix)
- path_to_source.update(_GetRelativePathToSourceDict(root, prefix=prefix))
-
- # Source paths
- for path in args:
- path_to_source[path] = source.Source(source.GetFileContents(path))
-
- # Source paths with alternate deps paths
- for path_with_depspath in options.paths_with_depspath:
- srcpath, depspath = _GetPair(path_with_depspath)
- path_to_source[depspath] = source.Source(source.GetFileContents(srcpath))
-
- # Make our output pipe.
- if options.output_file:
- out = open(options.output_file, 'w')
- else:
- out = sys.stdout
-
- out.write('// This file was autogenerated by %s.\n' % sys.argv[0])
- out.write('// Please do not edit.\n')
-
- out.write(MakeDepsFile(path_to_source))
-
-
-if __name__ == '__main__':
- main()
+++ /dev/null
-# Copyright 2009 The Closure Library Authors. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS-IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-"""Scans a source JS file for its provided and required namespaces.
-
-Simple class to scan a JavaScript file and express its dependencies.
-"""
-
-__author__ = 'nnaze@google.com'
-
-
-import re
-
-_BASE_REGEX_STRING = '^\s*goog\.%s\(\s*[\'"](.+)[\'"]\s*\)'
-_PROVIDE_REGEX = re.compile(_BASE_REGEX_STRING % 'provide')
-_REQUIRES_REGEX = re.compile(_BASE_REGEX_STRING % 'require')
-
-# This line identifies base.js and should match the line in that file.
-_GOOG_BASE_LINE = (
- 'var goog = goog || {}; // Identifies this file as the Closure base.')
-
-
-class Source(object):
- """Scans a JavaScript source for its provided and required namespaces."""
-
- # Matches a "/* ... */" comment.
- # Note: We can't definitively distinguish a "/*" in a string literal without a
- # state machine tokenizer. We'll assume that a line starting with whitespace
- # and "/*" is a comment.
- _COMMENT_REGEX = re.compile(
- r"""
- ^\s* # Start of a new line and whitespace
- /\* # Opening "/*"
- .*? # Non greedy match of any characters (including newlines)
- \*/ # Closing "*/""",
- re.MULTILINE | re.DOTALL | re.VERBOSE)
-
- def __init__(self, source):
- """Initialize a source.
-
- Args:
- source: str, The JavaScript source.
- """
-
- self.provides = set()
- self.requires = set()
-
- self._source = source
- self._ScanSource()
-
- def __str__(self):
- return 'Source %s' % self._path
-
- def GetSource(self):
- """Get the source as a string."""
- return self._source
-
- @classmethod
- def _StripComments(cls, source):
- return cls._COMMENT_REGEX.sub('', source)
-
- def _ScanSource(self):
- """Fill in provides and requires by scanning the source."""
-
- source = self._StripComments(self.GetSource())
-
- source_lines = source.splitlines()
- for line in source_lines:
- match = _PROVIDE_REGEX.match(line)
- if match:
- self.provides.add(match.group(1))
- match = _REQUIRES_REGEX.match(line)
- if match:
- self.requires.add(match.group(1))
-
- # Closure's base file implicitly provides 'goog'.
- for line in source_lines:
- if line == _GOOG_BASE_LINE:
- if len(self.provides) or len(self.requires):
- raise Exception(
- 'Base files should not provide or require namespaces.')
- self.provides.add('goog')
-
-
-def GetFileContents(path):
- """Get a file's contents as a string.
-
- Args:
- path: str, Path to file.
-
- Returns:
- str, Contents of file.
-
- Raises:
- IOError: An error occurred opening or reading the file.
-
- """
- fileobj = open(path)
- try:
- return fileobj.read()
- finally:
- fileobj.close()
+++ /dev/null
-#!/usr/bin/env python
-#
-# Copyright 2010 The Closure Library Authors. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS-IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-"""Shared utility functions for scanning directory trees."""
-
-import os
-import re
-
-
-__author__ = 'nnaze@google.com (Nathan Naze)'
-
-
-# Matches a .js file path.
-_JS_FILE_REGEX = re.compile(r'^.+\.js$')
-
-
-def ScanTreeForJsFiles(root):
- """Scans a directory tree for JavaScript files.
-
- Args:
- root: str, Path to a root directory.
-
- Returns:
- An iterable of paths to JS files, relative to cwd.
- """
- return ScanTree(root, path_filter=_JS_FILE_REGEX)
-
-
-def ScanTree(root, path_filter=None, ignore_hidden=True):
- """Scans a directory tree for files.
-
- Args:
- root: str, Path to a root directory.
- path_filter: A regular expression filter. If set, only paths matching
- the path_filter are returned.
- ignore_hidden: If True, do not follow or return hidden directories or files
- (those starting with a '.' character).
-
- Yields:
- A string path to files, relative to cwd.
- """
-
- def OnError(os_error):
- raise os_error
-
- for dirpath, dirnames, filenames in os.walk(root, onerror=OnError):
- # os.walk allows us to modify dirnames to prevent decent into particular
- # directories. Avoid hidden directories.
- for dirname in dirnames:
- if ignore_hidden and dirname.startswith('.'):
- dirnames.remove(dirname)
-
- for filename in filenames:
-
- # nothing that starts with '.'
- if ignore_hidden and filename.startswith('.'):
- continue
-
- fullpath = os.path.join(dirpath, filename)
-
- if path_filter and not path_filter.match(fullpath):
- continue
-
- yield os.path.normpath(fullpath)
+++ /dev/null
-/**
- * defines
- */
-
-goog.provide('USE_TYPEDARRAY');
-
-// Safari が typeof Uint8Array === 'object' になるため、
-// 未定義か否かで Typed Array の使用を決定する
-
-/** @const {boolean} use typed array flag. */
-var USE_TYPEDARRAY =
- (typeof Uint8Array !== 'undefined') &&
- (typeof Uint16Array !== 'undefined') &&
- (typeof Uint32Array !== 'undefined');
+++ /dev/null
-/**
- * typed array defines
- */
-
-goog.provide('USE_TYPEDARRAY');
-
-/** @define {boolean} use typed array flag. */
-var USE_TYPEDARRAY = true;
-
+++ /dev/null
-// This file was autogenerated by closure-primitives/depswriter.py.
-// Please do not edit.
-goog.addDependency('../bin/zlib.pretty.js', ['USE_TYPEDARRAY', 'Zlib', 'Zlib.Adler32', 'Zlib.BitStream', 'Zlib.CRC32', 'Zlib.Deflate', 'Zlib.Gunzip', 'Zlib.GunzipMember', 'Zlib.Gzip', 'Zlib.Heap', 'Zlib.Huffman', 'Zlib.Inflate', 'Zlib.InflateStream', 'Zlib.RawDeflate', 'Zlib.RawInflate', 'Zlib.RawInflateStream', 'Zlib.Unzip', 'Zlib.Util', 'Zlib.Zip', 'Zlib.exportObject'], ['USE_TYPEDARRAY', 'Zlib', 'Zlib.Adler32', 'Zlib.BitStream', 'Zlib.CRC32', 'Zlib.Deflate', 'Zlib.Gunzip', 'Zlib.GunzipMember', 'Zlib.Gzip', 'Zlib.Heap', 'Zlib.Huffman', 'Zlib.Inflate', 'Zlib.InflateStream', 'Zlib.RawDeflate', 'Zlib.RawInflate', 'Zlib.RawInflateStream', 'Zlib.Unzip', 'Zlib.Util', 'Zlib.Zip', 'Zlib.exportObject']);
-goog.addDependency('../closure-primitives/base.js', ['goog'], []);
-goog.addDependency('../define/typedarray/hybrid.js', ['USE_TYPEDARRAY'], []);
-goog.addDependency('../define/typedarray/use.js', ['USE_TYPEDARRAY'], []);
-goog.addDependency('../src/adler32.js', ['Zlib.Adler32'], ['USE_TYPEDARRAY', 'Zlib.Util']);
-goog.addDependency('../src/bitstream.js', ['Zlib.BitStream'], ['USE_TYPEDARRAY']);
-goog.addDependency('../src/crc32.js', ['Zlib.CRC32'], ['USE_TYPEDARRAY']);
-goog.addDependency('../src/deflate.js', ['Zlib.Deflate'], ['USE_TYPEDARRAY', 'Zlib', 'Zlib.Adler32', 'Zlib.RawDeflate']);
-goog.addDependency('../src/export_object.js', ['Zlib.exportObject'], ['Zlib']);
-goog.addDependency('../src/gunzip.js', ['Zlib.Gunzip'], ['USE_TYPEDARRAY', 'Zlib.CRC32', 'Zlib.GunzipMember', 'Zlib.Gzip', 'Zlib.RawInflate']);
-goog.addDependency('../src/gunzip_member.js', ['Zlib.GunzipMember'], []);
-goog.addDependency('../src/gzip.js', ['Zlib.Gzip'], ['USE_TYPEDARRAY', 'Zlib.CRC32', 'Zlib.RawDeflate']);
-goog.addDependency('../src/heap.js', ['Zlib.Heap'], ['USE_TYPEDARRAY']);
-goog.addDependency('../src/huffman.js', ['Zlib.Huffman'], ['USE_TYPEDARRAY']);
-goog.addDependency('../src/inflate.js', ['Zlib.Inflate'], ['USE_TYPEDARRAY', 'Zlib.Adler32', 'Zlib.RawInflate']);
-goog.addDependency('../src/inflate_stream.js', ['Zlib.InflateStream'], ['USE_TYPEDARRAY', 'Zlib', 'Zlib.RawInflateStream']);
-goog.addDependency('../src/rawdeflate.js', ['Zlib.RawDeflate'], ['USE_TYPEDARRAY', 'Zlib.BitStream', 'Zlib.Heap']);
-goog.addDependency('../src/rawinflate.js', ['Zlib.RawInflate'], ['USE_TYPEDARRAY', 'Zlib.Huffman']);
-goog.addDependency('../src/rawinflate_stream.js', ['Zlib.RawInflateStream'], ['USE_TYPEDARRAY', 'Zlib.Huffman']);
-goog.addDependency('../src/unzip.js', ['Zlib.Unzip'], ['USE_TYPEDARRAY', 'Zlib.CRC32', 'Zlib.RawInflate', 'Zlib.Zip']);
-goog.addDependency('../src/util.js', ['Zlib.Util'], []);
-goog.addDependency('../src/zip.js', ['Zlib.Zip'], ['USE_TYPEDARRAY', 'Zlib.CRC32', 'Zlib.RawDeflate']);
-goog.addDependency('../src/zlib.js', ['Zlib'], []);
+++ /dev/null
-goog.require('Zlib.Adler32');
-
-goog.exportSymbol('Zlib.Adler32', Zlib.Adler32);
-goog.exportSymbol('Zlib.Adler32.update', Zlib.Adler32.update);
+++ /dev/null
-goog.require('Zlib.CRC32');
-
-goog.exportSymbol('Zlib.CRC32', Zlib.CRC32);
-goog.exportSymbol('Zlib.CRC32.calc', Zlib.CRC32.calc);
-goog.exportSymbol('Zlib.CRC32.update', Zlib.CRC32.update);
\ No newline at end of file
+++ /dev/null
-goog.require('Zlib.Deflate');
-goog.require('Zlib.exportObject');
-
-goog.exportSymbol('Zlib.Deflate', Zlib.Deflate);
-goog.exportSymbol(
- 'Zlib.Deflate.compress',
- Zlib.Deflate.compress
-);
-goog.exportSymbol(
- 'Zlib.Deflate.prototype.compress',
- Zlib.Deflate.prototype.compress
-);
-Zlib.exportObject('Zlib.Deflate.CompressionType', {
- 'NONE': Zlib.Deflate.CompressionType.NONE,
- 'FIXED': Zlib.Deflate.CompressionType.FIXED,
- 'DYNAMIC': Zlib.Deflate.CompressionType.DYNAMIC
-});
+++ /dev/null
-goog.require('Zlib.Gunzip');
-
-goog.exportSymbol('Zlib.Gunzip', Zlib.Gunzip);
-goog.exportSymbol(
- 'Zlib.Gunzip.prototype.decompress',
- Zlib.Gunzip.prototype.decompress
-);
-goog.exportSymbol(
- 'Zlib.Gunzip.prototype.getMembers',
- Zlib.Gunzip.prototype.getMembers
-);
+++ /dev/null
-goog.require('Zlib.GunzipMember');
-
-goog.exportSymbol('Zlib.GunzipMember', Zlib.GunzipMember);
-goog.exportSymbol(
- 'Zlib.GunzipMember.prototype.getName',
- Zlib.GunzipMember.prototype.getName
-);
-goog.exportSymbol(
- 'Zlib.GunzipMember.prototype.getData',
- Zlib.GunzipMember.prototype.getData
-);
-goog.exportSymbol(
- 'Zlib.GunzipMember.prototype.getMtime',
- Zlib.GunzipMember.prototype.getMtime
-);
\ No newline at end of file
+++ /dev/null
-goog.require('Zlib.Gzip');
-
-goog.exportSymbol('Zlib.Gzip', Zlib.Gzip);
-goog.exportSymbol(
- 'Zlib.Gzip.prototype.compress',
- Zlib.Gzip.prototype.compress
-);
\ No newline at end of file
+++ /dev/null
-goog.require('Zlib.Inflate');
-goog.require('Zlib.exportObject');
-
-goog.exportSymbol('Zlib.Inflate', Zlib.Inflate);
-goog.exportSymbol(
- 'Zlib.Inflate.prototype.decompress',
- Zlib.Inflate.prototype.decompress
-);
-Zlib.exportObject('Zlib.Inflate.BufferType', {
- 'ADAPTIVE': Zlib.Inflate.BufferType.ADAPTIVE,
- 'BLOCK': Zlib.Inflate.BufferType.BLOCK
-});
+++ /dev/null
-goog.require('Zlib.InflateStream');
-
-goog.exportSymbol('Zlib.InflateStream', Zlib.InflateStream);
-goog.exportSymbol(
- 'Zlib.InflateStream.prototype.decompress',
- Zlib.InflateStream.prototype.decompress
-);
-goog.exportSymbol(
- 'Zlib.InflateStream.prototype.getBytes',
- Zlib.InflateStream.prototype.getBytes
-);
\ No newline at end of file
+++ /dev/null
-goog.require('Zlib.RawDeflate');
-goog.require('Zlib.exportObject');
-
-goog.exportSymbol(
- 'Zlib.RawDeflate',
- Zlib.RawDeflate
-);
-
-goog.exportSymbol(
- 'Zlib.RawDeflate.prototype.compress',
- Zlib.RawDeflate.prototype.compress
-);
-
-Zlib.exportObject(
- 'Zlib.RawDeflate.CompressionType',
- {
- 'NONE': Zlib.RawDeflate.CompressionType.NONE,
- 'FIXED': Zlib.RawDeflate.CompressionType.FIXED,
- 'DYNAMIC': Zlib.RawDeflate.CompressionType.DYNAMIC
- }
-);
+++ /dev/null
-goog.require('Zlib.RawInflate');
-goog.require('Zlib.exportObject');
-
-goog.exportSymbol('Zlib.RawInflate', Zlib.RawInflate);
-goog.exportSymbol(
- 'Zlib.RawInflate.prototype.decompress',
- Zlib.RawInflate.prototype.decompress
-);
-Zlib.exportObject('Zlib.RawInflate.BufferType', {
- 'ADAPTIVE': Zlib.RawInflate.BufferType.ADAPTIVE,
- 'BLOCK': Zlib.RawInflate.BufferType.BLOCK
-});
+++ /dev/null
-goog.require('Zlib.RawInflateStream');
-
-goog.exportSymbol('Zlib.RawInflateStream', Zlib.RawInflateStream);
-goog.exportSymbol(
- 'Zlib.RawInflateStream.prototype.decompress',
- Zlib.RawInflateStream.prototype.decompress
-);
-goog.exportSymbol(
- 'Zlib.RawInflateStream.prototype.getBytes',
- Zlib.RawInflateStream.prototype.getBytes
-);
\ No newline at end of file
+++ /dev/null
-goog.require('Zlib.Unzip');
-
-goog.exportSymbol('Zlib.Unzip', Zlib.Unzip);
-goog.exportSymbol(
- 'Zlib.Unzip.prototype.decompress',
- Zlib.Unzip.prototype.decompress
-);
-goog.exportSymbol(
- 'Zlib.Unzip.prototype.getFilenames',
- Zlib.Unzip.prototype.getFilenames
-);
-goog.exportSymbol(
- 'Zlib.Unzip.prototype.setPassword',
- Zlib.Unzip.prototype.setPassword
-);
\ No newline at end of file
+++ /dev/null
-goog.require('Zlib.Zip');
-goog.require('Zlib.exportObject');
-
-goog.exportSymbol(
- 'Zlib.Zip',
- Zlib.Zip
-);
-goog.exportSymbol(
- 'Zlib.Zip.prototype.addFile',
- Zlib.Zip.prototype.addFile
-);
-goog.exportSymbol(
- 'Zlib.Zip.prototype.compress',
- Zlib.Zip.prototype.compress
-);
-goog.exportSymbol(
- 'Zlib.Zip.prototype.setPassword',
- Zlib.Zip.prototype.setPassword
-);
-Zlib.exportObject(
- 'Zlib.Zip.CompressionMethod', {
- 'STORE': Zlib.Zip.CompressionMethod.STORE,
- 'DEFLATE': Zlib.Zip.CompressionMethod.DEFLATE
- }
-);
-Zlib.exportObject(
- 'Zlib.Zip.OperatingSystem', {
- 'MSDOS': Zlib.Zip.OperatingSystem.MSDOS,
- 'UNIX': Zlib.Zip.OperatingSystem.UNIX,
- 'MACINTOSH': Zlib.Zip.OperatingSystem.MACINTOSH
- }
-);
-// TODO: Deflate Option
\ No newline at end of file
+++ /dev/null
-/**
- * zlib.js wrapper for node.js
- */
-goog.require('Zlib.Inflate');
-goog.require('Zlib.Deflate');
-goog.require('Zlib.Gunzip');
-
-//-----------------------------------------------------------------------------
-// exports methods
-//-----------------------------------------------------------------------------
-exports['deflate'] = deflate;
-exports['deflateSync'] = deflateSync;
-exports['inflate'] = inflate;
-exports['inflateSync'] = inflateSync;
-exports['gzip'] = gzip;
-exports['gzipSync'] = gzipSync;
-exports['gunzip'] = gunzip;
-exports['gunzipSync'] = gunzipSync;
-
-
-/**
- * deflate async.
- * @param {!(Buffer|Array.<number>|Uint8Array)} buffer plain data buffer.
- * @param {function(Error, !(Buffer|Array.<number>|Uint8Array))} callback
- * error calllback function.
- * @param {Object=} opt_params option parameters.
- */
-function deflate(buffer, callback, opt_params) {
- process.nextTick(function(){
- /** @type {Error} error */
- var error;
- /** @type {!(Buffer|Array.<number>|Uint8Array)} deflated buffer. */
- var deflated;
-
- try {
- deflated = deflateSync(buffer, opt_params);
- } catch(e){
- error = e;
- }
-
- callback(error, deflated);
- });
-}
-
-
-/**
- * deflate sync.
- * @param {!(Buffer|Array.<number>|Uint8Array)} buffer plain data buffer.
- * @param {Object=} opt_params option parameters.
- * @return {!(Buffer|Array.<number>|Uint8Array)} deflated buffer.
- */
-function deflateSync(buffer, opt_params) {
- /** @type {Zlib.Deflate} deflate encoder. */
- var deflate = new Zlib.Deflate(
- /** @type {!(Array.<number>|Uint8Array)} */(buffer)
- );
- /** @type {!(Array.<number>|Uint8Array)} deflated buffer. */
- var deflated;
-
- deflated = deflate.compress();
-
- if (!opt_params) {
- opt_params = {};
- }
-
- return opt_params.noBuffer ? deflated : toBuffer(deflated);
-}
-
-
-/**
- * inflate async.
- * @param {!(Array.<number>|Uint8Array)} buffer deflated buffer.
- * @param {function(Error, !(Buffer|Array.<number>|Uint8Array))} callback
- * error calllback function.
- * @param {Object=} opt_params option parameters.
- */
-function inflate(buffer, callback, opt_params) {
- process.nextTick(function(){
- /** @type {Error} error */
- var error;
- /** @type {!(Buffer|Array.<number>|Uint8Array)} inflated plain buffer. */
- var inflated;
-
- try {
- inflated = inflateSync(buffer, opt_params);
- } catch(e){
- error = e;
- }
-
- callback(error, inflated);
- });
-};
-
-
-/**
- * inflate sync.
- * @param {!(Array.<number>|Uint8Array)} buffer deflated buffer.
- * @param {Object=} opt_params option parameters.
- * @return {!(Buffer|Array.<number>|Uint8Array)} inflated plain buffer.
- */
-function inflateSync(buffer, opt_params) {
- /** @type {Zlib.Inflate} deflate decoder. */
- var inflate;
- /** @type {!(Buffer|Array.<number>|Uint8Array)} inflated plain buffer. */
- var inflated;
-
- buffer.subarray = buffer.slice;
- inflate = new Zlib.Inflate(buffer);
- inflated = inflate.decompress();
-
- if (!opt_params) {
- opt_params = {};
- }
-
- return opt_params['noBuffer'] ? inflated : toBuffer(inflated);
-}
-
-/**
- * gunzip async.
- * @param {!(Array.<number>|Uint8Array)} buffer inflated buffer.
- * @param {function(Error, !(Buffer|Array.<number>|Uint8Array))} callback
- * error calllback function.
- * @param {Object=} opt_params option parameters.
- */
-function gzip(buffer, callback, opt_params) {
- process.nextTick(function(){
- /** @type {Error} error */
- var error;
- /** @type {!(Buffer|Array.<number>|Uint8Array)} deflated buffer. */
- var deflated;
-
- try {
- deflated = gzipSync(buffer, opt_params);
- } catch(e){
- error = e;
- }
-
- callback(error, deflated);
- });
-}
-
-/**
- * deflate sync.
- * @param {!(Array.<number>|Uint8Array)} buffer inflated buffer.
- * @param {Object=} opt_params option parameters.
- * @return {!(Buffer|Array.<number>|Uint8Array)} deflated buffer.
- */
-function gzipSync(buffer, opt_params) {
- /** @type {Zlib.Gzip} deflate compressor. */
- var deflate;
- /** @type {!(Buffer|Array.<number>|Uint8Array)} deflated buffer. */
- var deflated;
-
- buffer.subarray = buffer.slice;
- deflate = new Zlib.Gzip(buffer);
- deflated = deflate.compress();
-
- if (!opt_params) {
- opt_params = {};
- }
-
- return opt_params.noBuffer ? deflated : toBuffer(deflated);
-}
-
-/**
- * gunzip async.
- * @param {!(Array.<number>|Uint8Array)} buffer deflated buffer.
- * @param {function(Error, !(Buffer|Array.<number>|Uint8Array))} callback
- * error calllback function.
- * @param {Object=} opt_params option parameters.
- */
-function gunzip(buffer, callback, opt_params) {
- process.nextTick(function(){
- /** @type {Error} error */
- var error;
- /** @type {!(Buffer|Array.<number>|Uint8Array)} inflated plain buffer. */
- var inflated;
-
- try {
- inflated = gunzipSync(buffer, opt_params);
- } catch(e){
- error = e;
- }
-
- callback(error, inflated);
- });
-}
-
-/**
- * inflate sync.
- * @param {!(Array.<number>|Uint8Array)} buffer deflated buffer.
- * @param {Object=} opt_params option parameters.
- * @return {!(Buffer|Array.<number>|Uint8Array)} inflated plain buffer.
- */
-function gunzipSync(buffer, opt_params) {
- /** @type {Zlib.Gunzip} deflate decompressor. */
- var inflate;
- /** @type {!(Buffer|Array.<number>|Uint8Array)} inflated plain buffer. */
- var inflated;
-
- buffer.subarray = buffer.slice;
- inflate = new Zlib.Gunzip(buffer);
- inflated = inflate.decompress();
-
- if (!opt_params) {
- opt_params = {};
- }
-
- return opt_params.noBuffer ? inflated : toBuffer(inflated);
-}
-
-
-/**
- * convert to Buffer.
- * @param {!(Array.<number>|Uint8Array)} array arraylike object.
- * @return {!Buffer} Buffer object.
- */
-function toBuffer(array) {
- var buffer = new Buffer(array.length);
- var i;
- var il;
-
- // TODO: loop unrolling for performance
- for (i = 0, il = array.length; i < il; ++i) {
- buffer[i] = array[i];
- }
-
- return buffer;
-}
-
+++ /dev/null
-/** @type {Object} namespace. */
-var exports;
-
-/** @type {Object} namespace. */
-var process = {};
-/** @param {function()} func exec function. */
-process.nextTick = function(func) {};
-
-/** @constructor */
-var Buffer = function(arg){};
-
-var console = {};
-console.log = function(){};
+++ /dev/null
-{
- "author": {
- "name": "Yuta Imaya"
- },
- "contributors": {
- "name": "Yuta Imaya",
- "email": "imaya.devel@gmail.com"
- },
- "name": "zlibjs",
- "description": "zlib, gzip and zip implementation in JavaScript",
- "version": "0.1.6",
- "main": "./bin/node-zlib.js",
- "homepage": "https://github.com/imaya/zlib.js",
- "repository": {
- "type": "git",
- "url": "git://github.com/imaya/zlib.js.git"
- },
- "dependencies" : {
- "buster" : ">=0.6.3"
- },
- "devDependencies": {},
- "optionalDependencies": {},
- "engines": {
- "node": "*"
- },
- "scripts" : {
- "test" : "node_modules/.bin/buster-test"
- }
-}
+++ /dev/null
-/**
- * @fileoverview Adler32 checksum 実装.
- */
-goog.provide('Zlib.Adler32');
-
-goog.require('USE_TYPEDARRAY');
-goog.require('Zlib.Util');
-
-goog.scope(function() {
-
-/**
- * Adler32 ハッシュ値の作成
- * @param {!(Array|Uint8Array|string)} array 算出に使用する byte array.
- * @return {number} Adler32 ハッシュ値.
- */
-Zlib.Adler32 = function(array) {
- if (typeof(array) === 'string') {
- array = Zlib.Util.stringToByteArray(array);
- }
- return Zlib.Adler32.update(1, array);
-};
-
-/**
- * Adler32 ハッシュ値の更新
- * @param {number} adler 現在のハッシュ値.
- * @param {!(Array|Uint8Array)} array 更新に使用する byte array.
- * @return {number} Adler32 ハッシュ値.
- */
-Zlib.Adler32.update = function(adler, array) {
- /** @type {number} */
- var s1 = adler & 0xffff;
- /** @type {number} */
- var s2 = (adler >>> 16) & 0xffff;
- /** @type {number} array length */
- var len = array.length;
- /** @type {number} loop length (don't overflow) */
- var tlen;
- /** @type {number} array index */
- var i = 0;
-
- while (len > 0) {
- tlen = len > Zlib.Adler32.OptimizationParameter ?
- Zlib.Adler32.OptimizationParameter : len;
- len -= tlen;
- do {
- s1 += array[i++];
- s2 += s1;
- } while (--tlen);
-
- s1 %= 65521;
- s2 %= 65521;
- }
-
- return ((s2 << 16) | s1) >>> 0;
-};
-
-/**
- * Adler32 最適化パラメータ
- * 現状では 1024 程度が最適.
- * @see http://jsperf.com/adler-32-simple-vs-optimized/3
- * @define {number}
- */
-Zlib.Adler32.OptimizationParameter = 1024;
-
-// end of scope
-});
-
-/* vim:set expandtab ts=2 sw=2 tw=80: */
+++ /dev/null
-/**
- * @fileoverview bit 単位での書き込み実装.
- */
-goog.provide('Zlib.BitStream');
-
-goog.require('USE_TYPEDARRAY');
-
-goog.scope(function() {
-
-/**
- * ビットストリーム
- * @constructor
- * @param {!(Array|Uint8Array)=} buffer output buffer.
- * @param {number=} bufferPosition start buffer pointer.
- */
-Zlib.BitStream = function(buffer, bufferPosition) {
- /** @type {number} buffer index. */
- this.index = typeof bufferPosition === 'number' ? bufferPosition : 0;
- /** @type {number} bit index. */
- this.bitindex = 0;
- /** @type {!(Array|Uint8Array)} bit-stream output buffer. */
- this.buffer = buffer instanceof (USE_TYPEDARRAY ? Uint8Array : Array) ?
- buffer :
- new (USE_TYPEDARRAY ? Uint8Array : Array)(Zlib.BitStream.DefaultBlockSize);
-
- // 入力された index が足りなかったら拡張するが、倍にしてもダメなら不正とする
- if (this.buffer.length * 2 <= this.index) {
- throw new Error("invalid index");
- } else if (this.buffer.length <= this.index) {
- this.expandBuffer();
- }
-};
-
-/**
- * デフォルトブロックサイズ.
- * @const
- * @type {number}
- */
-Zlib.BitStream.DefaultBlockSize = 0x8000;
-
-/**
- * expand buffer.
- * @return {!(Array|Uint8Array)} new buffer.
- */
-Zlib.BitStream.prototype.expandBuffer = function() {
- /** @type {!(Array|Uint8Array)} old buffer. */
- var oldbuf = this.buffer;
- /** @type {number} loop counter. */
- var i;
- /** @type {number} loop limiter. */
- var il = oldbuf.length;
- /** @type {!(Array|Uint8Array)} new buffer. */
- var buffer =
- new (USE_TYPEDARRAY ? Uint8Array : Array)(il << 1);
-
- // copy buffer
- if (USE_TYPEDARRAY) {
- buffer.set(oldbuf);
- } else {
- // XXX: loop unrolling
- for (i = 0; i < il; ++i) {
- buffer[i] = oldbuf[i];
- }
- }
-
- return (this.buffer = buffer);
-};
-
-
-/**
- * 数値をビットで指定した数だけ書き込む.
- * @param {number} number 書き込む数値.
- * @param {number} n 書き込むビット数.
- * @param {boolean=} reverse 逆順に書き込むならば true.
- */
-Zlib.BitStream.prototype.writeBits = function(number, n, reverse) {
- var buffer = this.buffer;
- var index = this.index;
- var bitindex = this.bitindex;
-
- /** @type {number} current octet. */
- var current = buffer[index];
- /** @type {number} loop counter. */
- var i;
-
- /**
- * 32-bit 整数のビット順を逆にする
- * @param {number} n 32-bit integer.
- * @return {number} reversed 32-bit integer.
- * @private
- */
- function rev32_(n) {
- return (Zlib.BitStream.ReverseTable[n & 0xFF] << 24) |
- (Zlib.BitStream.ReverseTable[n >>> 8 & 0xFF] << 16) |
- (Zlib.BitStream.ReverseTable[n >>> 16 & 0xFF] << 8) |
- Zlib.BitStream.ReverseTable[n >>> 24 & 0xFF];
- }
-
- if (reverse && n > 1) {
- number = n > 8 ?
- rev32_(number) >> (32 - n) :
- Zlib.BitStream.ReverseTable[number] >> (8 - n);
- }
-
- // Byte 境界を超えないとき
- if (n + bitindex < 8) {
- current = (current << n) | number;
- bitindex += n;
- // Byte 境界を超えるとき
- } else {
- for (i = 0; i < n; ++i) {
- current = (current << 1) | ((number >> n - i - 1) & 1);
-
- // next byte
- if (++bitindex === 8) {
- bitindex = 0;
- buffer[index++] = Zlib.BitStream.ReverseTable[current];
- current = 0;
-
- // expand
- if (index === buffer.length) {
- buffer = this.expandBuffer();
- }
- }
- }
- }
- buffer[index] = current;
-
- this.buffer = buffer;
- this.bitindex = bitindex;
- this.index = index;
-};
-
-
-/**
- * ストリームの終端処理を行う
- * @return {!(Array|Uint8Array)} 終端処理後のバッファを byte array で返す.
- */
-Zlib.BitStream.prototype.finish = function() {
- var buffer = this.buffer;
- var index = this.index;
-
- /** @type {!(Array|Uint8Array)} output buffer. */
- var output;
-
- // bitindex が 0 の時は余分に index が進んでいる状態
- if (this.bitindex > 0) {
- buffer[index] <<= 8 - this.bitindex;
- buffer[index] = Zlib.BitStream.ReverseTable[buffer[index]];
- index++;
- }
-
- // array truncation
- if (USE_TYPEDARRAY) {
- output = buffer.subarray(0, index);
- } else {
- buffer.length = index;
- output = buffer;
- }
-
- return output;
-};
-
-/**
- * 0-255 のビット順を反転したテーブル
- * @const
- * @type {!(Uint8Array|Array.<number>)}
- */
-Zlib.BitStream.ReverseTable = (function(table) {
- return table;
-})((function() {
- /** @type {!(Array|Uint8Array)} reverse table. */
- var table = new (USE_TYPEDARRAY ? Uint8Array : Array)(256);
- /** @type {number} loop counter. */
- var i;
- /** @type {number} loop limiter. */
- var il;
-
- // generate
- for (i = 0; i < 256; ++i) {
- table[i] = (function(n) {
- var r = n;
- var s = 7;
-
- for (n >>>= 1; n; n >>>= 1) {
- r <<= 1;
- r |= n & 1;
- --s;
- }
-
- return (r << s & 0xff) >>> 0;
- })(i);
- }
-
- return table;
-})());
-
-
-// end of scope
-});
-
-/* vim:set expandtab ts=2 sw=2 tw=80: */
+++ /dev/null
-/**
- * @fileoverview CRC32 実装.
- */
-goog.provide('Zlib.CRC32');
-
-goog.require('USE_TYPEDARRAY');
-
-/** @define {boolean} */
-var ZLIB_CRC32_COMPACT = false;
-
-goog.scope(function() {
-
-/**
- * CRC32 ハッシュ値を取得
- * @param {!(Array.<number>|Uint8Array)} data data byte array.
- * @param {number=} pos data position.
- * @param {number=} length data length.
- * @return {number} CRC32.
- */
-Zlib.CRC32.calc = function(data, pos, length) {
- return Zlib.CRC32.update(data, 0, pos, length);
-};
-
-/**
- * CRC32ハッシュ値を更新
- * @param {!(Array.<number>|Uint8Array)} data data byte array.
- * @param {number} crc CRC32.
- * @param {number=} pos data position.
- * @param {number=} length data length.
- * @return {number} CRC32.
- */
-Zlib.CRC32.update = function(data, crc, pos, length) {
- var table = Zlib.CRC32.Table;
- var i = (typeof pos === 'number') ? pos : (pos = 0);
- var il = (typeof length === 'number') ? length : data.length;
-
- crc ^= 0xffffffff;
-
- // loop unrolling for performance
- for (i = il & 7; i--; ++pos) {
- crc = (crc >>> 8) ^ table[(crc ^ data[pos]) & 0xff];
- }
- for (i = il >> 3; i--; pos += 8) {
- crc = (crc >>> 8) ^ table[(crc ^ data[pos ]) & 0xff];
- crc = (crc >>> 8) ^ table[(crc ^ data[pos + 1]) & 0xff];
- crc = (crc >>> 8) ^ table[(crc ^ data[pos + 2]) & 0xff];
- crc = (crc >>> 8) ^ table[(crc ^ data[pos + 3]) & 0xff];
- crc = (crc >>> 8) ^ table[(crc ^ data[pos + 4]) & 0xff];
- crc = (crc >>> 8) ^ table[(crc ^ data[pos + 5]) & 0xff];
- crc = (crc >>> 8) ^ table[(crc ^ data[pos + 6]) & 0xff];
- crc = (crc >>> 8) ^ table[(crc ^ data[pos + 7]) & 0xff];
- }
-
- return (crc ^ 0xffffffff) >>> 0;
-};
-
-/**
- * @param {number} num
- * @param {number} crc
- * @returns {number}
- */
-Zlib.CRC32.single = function(num, crc) {
- return (Zlib.CRC32.Table[(num ^ crc) & 0xff] ^ (num >>> 8)) >>> 0;
-};
-
-/**
- * @type {Array.<number>}
- * @const
- * @private
- */
-Zlib.CRC32.Table_ = [
- 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
- 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
- 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
- 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
- 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
- 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
- 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
- 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
- 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
- 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
- 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
- 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
- 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
- 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
- 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
- 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
- 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
- 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
- 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
- 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
- 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
- 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
- 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
- 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
- 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
- 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
- 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
- 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
- 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
- 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
- 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
- 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
- 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
- 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
- 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
- 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
- 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
- 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
- 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
- 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
- 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
- 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
- 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
-];
-
-/**
- * @type {!(Array.<number>|Uint32Array)} CRC-32 Table.
- * @const
- */
-Zlib.CRC32.Table = ZLIB_CRC32_COMPACT ? (function() {
- /** @type {!(Array.<number>|Uint32Array)} */
- var table = new (USE_TYPEDARRAY ? Uint32Array : Array)(256);
- /** @type {number} */
- var c;
- /** @type {number} */
- var i;
- /** @type {number} */
- var j;
-
- for (i = 0; i < 256; ++i) {
- c = i;
- for (j = 0; j < 8; ++j) {
- c = (c & 1) ? (0xedB88320 ^ (c >>> 1)) : (c >>> 1);
- }
- table[i] = c >>> 0;
- }
-
- return table;
-})() : USE_TYPEDARRAY ? new Uint32Array(Zlib.CRC32.Table_) : Zlib.CRC32.Table_;
-
-});
+++ /dev/null
-/**
- * @fileoverview Deflate (RFC1951) 実装.
- * Deflateアルゴリズム本体は Zlib.RawDeflate で実装されている.
- */
-goog.provide('Zlib.Deflate');
-
-goog.require('USE_TYPEDARRAY');
-goog.require('Zlib');
-goog.require('Zlib.Adler32');
-goog.require('Zlib.RawDeflate');
-
-goog.scope(function() {
-
-/**
- * Zlib Deflate
- * @constructor
- * @param {!(Array|Uint8Array)} input 符号化する対象の byte array.
- * @param {Object=} opt_params option parameters.
- */
-Zlib.Deflate = function(input, opt_params) {
- /** @type {!(Array|Uint8Array)} */
- this.input = input;
- /** @type {!(Array|Uint8Array)} */
- this.output =
- new (USE_TYPEDARRAY ? Uint8Array : Array)(Zlib.Deflate.DefaultBufferSize);
- /** @type {Zlib.Deflate.CompressionType} */
- this.compressionType = Zlib.Deflate.CompressionType.DYNAMIC;
- /** @type {Zlib.RawDeflate} */
- this.rawDeflate;
- /** @type {Object} */
- var rawDeflateOption = {};
- /** @type {string} */
- var prop;
-
- // option parameters
- if (opt_params || !(opt_params = {})) {
- if (typeof opt_params['compressionType'] === 'number') {
- this.compressionType = opt_params['compressionType'];
- }
- }
-
- // copy options
- for (prop in opt_params) {
- rawDeflateOption[prop] = opt_params[prop];
- }
-
- // set raw-deflate output buffer
- rawDeflateOption['outputBuffer'] = this.output;
-
- this.rawDeflate = new Zlib.RawDeflate(this.input, rawDeflateOption);
-};
-
-/**
- * @const
- * @type {number} デフォルトバッファサイズ.
- */
-Zlib.Deflate.DefaultBufferSize = 0x8000;
-
-/**
- * @enum {number}
- */
-Zlib.Deflate.CompressionType = Zlib.RawDeflate.CompressionType;
-
-/**
- * 直接圧縮に掛ける.
- * @param {!(Array|Uint8Array)} input target buffer.
- * @param {Object=} opt_params option parameters.
- * @return {!(Array|Uint8Array)} compressed data byte array.
- */
-Zlib.Deflate.compress = function(input, opt_params) {
- return (new Zlib.Deflate(input, opt_params)).compress();
-};
-
-/**
- * Deflate Compression.
- * @return {!(Array|Uint8Array)} compressed data byte array.
- */
-Zlib.Deflate.prototype.compress = function() {
- /** @type {Zlib.CompressionMethod} */
- var cm;
- /** @type {number} */
- var cinfo;
- /** @type {number} */
- var cmf;
- /** @type {number} */
- var flg;
- /** @type {number} */
- var fcheck;
- /** @type {number} */
- var fdict;
- /** @type {number} */
- var flevel;
- /** @type {number} */
- var clevel;
- /** @type {number} */
- var adler;
- /** @type {boolean} */
- var error = false;
- /** @type {!(Array|Uint8Array)} */
- var output;
- /** @type {number} */
- var pos = 0;
-
- output = this.output;
-
- // Compression Method and Flags
- cm = Zlib.CompressionMethod.DEFLATE;
- switch (cm) {
- case Zlib.CompressionMethod.DEFLATE:
- cinfo = Math.LOG2E * Math.log(Zlib.RawDeflate.WindowSize) - 8;
- break;
- default:
- throw new Error('invalid compression method');
- }
- cmf = (cinfo << 4) | cm;
- output[pos++] = cmf;
-
- // Flags
- fdict = 0;
- switch (cm) {
- case Zlib.CompressionMethod.DEFLATE:
- switch (this.compressionType) {
- case Zlib.Deflate.CompressionType.NONE: flevel = 0; break;
- case Zlib.Deflate.CompressionType.FIXED: flevel = 1; break;
- case Zlib.Deflate.CompressionType.DYNAMIC: flevel = 2; break;
- default: throw new Error('unsupported compression type');
- }
- break;
- default:
- throw new Error('invalid compression method');
- }
- flg = (flevel << 6) | (fdict << 5);
- fcheck = 31 - (cmf * 256 + flg) % 31;
- flg |= fcheck;
- output[pos++] = flg;
-
- // Adler-32 checksum
- adler = Zlib.Adler32(this.input);
-
- this.rawDeflate.op = pos;
- output = this.rawDeflate.compress();
- pos = output.length;
-
- if (USE_TYPEDARRAY) {
- // subarray 分を元にもどす
- output = new Uint8Array(output.buffer);
- // expand buffer
- if (output.length <= pos + 4) {
- this.output = new Uint8Array(output.length + 4);
- this.output.set(output);
- output = this.output;
- }
- output = output.subarray(0, pos + 4);
- }
-
- // adler32
- output[pos++] = (adler >> 24) & 0xff;
- output[pos++] = (adler >> 16) & 0xff;
- output[pos++] = (adler >> 8) & 0xff;
- output[pos++] = (adler ) & 0xff;
-
- return output;
-};
-
-// end of scope
-});
-
-/* vim:set expandtab ts=2 sw=2 tw=80: */
+++ /dev/null
-goog.provide('Zlib.exportObject');
-
-goog.require('Zlib');
-
-goog.scope(function() {
-
-Zlib.exportObject = function(enumString, exportKeyValue) {
- /** @type {Array.<string>} */
- var keys;
- /** @type {string} */
- var key;
- /** @type {number} */
- var i;
- /** @type {number} */
- var il;
-
- if (Object.keys) {
- keys = Object.keys(exportKeyValue);
- } else {
- keys = [];
- i = 0;
- for (key in exportKeyValue) {
- keys[i++] = key;
- }
- }
-
- for (i = 0, il = keys.length; i < il; ++i) {
- key = keys[i];
- goog.exportSymbol(enumString + '.' + key, exportKeyValue[key])
- }
-};
-
-});
\ No newline at end of file
+++ /dev/null
-/**
- * @fileoverview GZIP (RFC1952) 展開コンテナ実装.
- */
-goog.provide('Zlib.Gunzip');
-
-goog.require('USE_TYPEDARRAY');
-goog.require('Zlib.CRC32');
-goog.require('Zlib.Gzip');
-goog.require('Zlib.RawInflate');
-goog.require('Zlib.GunzipMember');
-
-goog.scope(function() {
-
-/**
- * @constructor
- * @param {!(Array|Uint8Array)} input input buffer.
- * @param {Object=} opt_params option parameters.
- */
-Zlib.Gunzip = function(input, opt_params) {
- /** @type {!(Array.<number>|Uint8Array)} input buffer. */
- this.input = input;
- /** @type {number} input buffer pointer. */
- this.ip = 0;
- /** @type {Array.<Zlib.GunzipMember>} */
- this.member = [];
- /** @type {boolean} */
- this.decompressed = false;
-};
-
-/**
- * @return {Array.<Zlib.GunzipMember>}
- */
-Zlib.Gunzip.prototype.getMembers = function() {
- if (!this.decompressed) {
- this.decompress();
- }
-
- return this.member.slice();
-};
-
-/**
- * inflate gzip data.
- * @return {!(Array.<number>|Uint8Array)} inflated buffer.
- */
-Zlib.Gunzip.prototype.decompress = function() {
- /** @type {number} input length. */
- var il = this.input.length;
-
- while (this.ip < il) {
- this.decodeMember();
- }
-
- this.decompressed = true;
-
- return this.concatMember();
-};
-
-/**
- * decode gzip member.
- */
-Zlib.Gunzip.prototype.decodeMember = function() {
- /** @type {Zlib.GunzipMember} */
- var member = new Zlib.GunzipMember();
- /** @type {number} */
- var isize;
- /** @type {Zlib.RawInflate} RawInflate implementation. */
- var rawinflate;
- /** @type {!(Array.<number>|Uint8Array)} inflated data. */
- var inflated;
- /** @type {number} inflate size */
- var inflen;
- /** @type {number} character code */
- var c;
- /** @type {number} character index in string. */
- var ci;
- /** @type {Array.<string>} character array. */
- var str;
- /** @type {number} modification time. */
- var mtime;
- /** @type {number} */
- var crc32;
-
- var input = this.input;
- var ip = this.ip;
-
- member.id1 = input[ip++];
- member.id2 = input[ip++];
-
- // check signature
- if (member.id1 !== 0x1f || member.id2 !== 0x8b) {
- throw new Error('invalid file signature:' + member.id1 + ',' + member.id2);
- }
-
- // check compression method
- member.cm = input[ip++];
- switch (member.cm) {
- case 8: /* XXX: use Zlib const */
- break;
- default:
- throw new Error('unknown compression method: ' + member.cm);
- }
-
- // flags
- member.flg = input[ip++];
-
- // modification time
- mtime = (input[ip++]) |
- (input[ip++] << 8) |
- (input[ip++] << 16) |
- (input[ip++] << 24);
- member.mtime = new Date(mtime * 1000);
-
- // extra flags
- member.xfl = input[ip++];
-
- // operating system
- member.os = input[ip++];
-
- // extra
- if ((member.flg & Zlib.Gzip.FlagsMask.FEXTRA) > 0) {
- member.xlen = input[ip++] | (input[ip++] << 8);
- ip = this.decodeSubField(ip, member.xlen);
- }
-
- // fname
- if ((member.flg & Zlib.Gzip.FlagsMask.FNAME) > 0) {
- for(str = [], ci = 0; (c = input[ip++]) > 0;) {
- str[ci++] = String.fromCharCode(c);
- }
- member.name = str.join('');
- }
-
- // fcomment
- if ((member.flg & Zlib.Gzip.FlagsMask.FCOMMENT) > 0) {
- for(str = [], ci = 0; (c = input[ip++]) > 0;) {
- str[ci++] = String.fromCharCode(c);
- }
- member.comment = str.join('');
- }
-
- // fhcrc
- if ((member.flg & Zlib.Gzip.FlagsMask.FHCRC) > 0) {
- member.crc16 = Zlib.CRC32.calc(input, 0, ip) & 0xffff;
- if (member.crc16 !== (input[ip++] | (input[ip++] << 8))) {
- throw new Error('invalid header crc16');
- }
- }
-
- // isize を事前に取得すると展開後のサイズが分かるため、
- // inflate処理のバッファサイズが事前に分かり、高速になる
- isize = (input[input.length - 4]) | (input[input.length - 3] << 8) |
- (input[input.length - 2] << 16) | (input[input.length - 1] << 24);
-
- // isize の妥当性チェック
- // ハフマン符号では最小 2-bit のため、最大で 1/4 になる
- // LZ77 符号では 長さと距離 2-Byte で最大 258-Byte を表現できるため、
- // 1/128 になるとする
- // ここから入力バッファの残りが isize の 512 倍以上だったら
- // サイズ指定のバッファ確保は行わない事とする
- if (input.length - ip - /* CRC-32 */4 - /* ISIZE */4 < isize * 512) {
- inflen = isize;
- }
-
- // compressed block
- rawinflate = new Zlib.RawInflate(input, {'index': ip, 'bufferSize': inflen});
- member.data = inflated = rawinflate.decompress();
- ip = rawinflate.ip;
-
- // crc32
- member.crc32 = crc32 =
- ((input[ip++]) | (input[ip++] << 8) |
- (input[ip++] << 16) | (input[ip++] << 24)) >>> 0;
- if (Zlib.CRC32.calc(inflated) !== crc32) {
- throw new Error('invalid CRC-32 checksum: 0x' +
- Zlib.CRC32.calc(inflated).toString(16) + ' / 0x' + crc32.toString(16));
- }
-
- // input size
- member.isize = isize =
- ((input[ip++]) | (input[ip++] << 8) |
- (input[ip++] << 16) | (input[ip++] << 24)) >>> 0;
- if ((inflated.length & 0xffffffff) !== isize) {
- throw new Error('invalid input size: ' +
- (inflated.length & 0xffffffff) + ' / ' + isize);
- }
-
- this.member.push(member);
- this.ip = ip;
-};
-
-/**
- * サブフィールドのデコード
- * XXX: 現在は何もせずスキップする
- */
-Zlib.Gunzip.prototype.decodeSubField = function(ip, length) {
- return ip + length;
-};
-
-/**
- * @return {!(Array.<number>|Uint8Array)}
- */
-Zlib.Gunzip.prototype.concatMember = function() {
- /** @type {Array.<Zlib.GunzipMember>} */
- var member = this.member;
- /** @type {number} */
- var i;
- /** @type {number} */
- var il;
- /** @type {number} */
- var p = 0;
- /** @type {number} */
- var size = 0;
- /** @type {!(Array.<number>|Uint8Array)} */
- var buffer;
-
- for (i = 0, il = member.length; i < il; ++i) {
- size += member[i].data.length;
- }
-
- if (USE_TYPEDARRAY) {
- buffer = new Uint8Array(size);
- for (i = 0; i < il; ++i) {
- buffer.set(member[i].data, p);
- p += member[i].data.length;
- }
- } else {
- buffer = [];
- for (i = 0; i < il; ++i) {
- buffer[i] = member[i].data;
- }
- buffer = Array.prototype.concat.apply([], buffer);
- }
-
- return buffer;
-};
-
-});
-/* vim:set expandtab ts=2 sw=2 tw=80: */
+++ /dev/null
-goog.provide('Zlib.GunzipMember');
-
-goog.scope(function() {
-
-/**
- * @constructor
- */
-Zlib.GunzipMember = function() {
- /** @type {number} signature first byte. */
- this.id1;
- /** @type {number} signature second byte. */
- this.id2;
- /** @type {number} compression method. */
- this.cm;
- /** @type {number} flags. */
- this.flg;
- /** @type {Date} modification time. */
- this.mtime;
- /** @type {number} extra flags. */
- this.xfl;
- /** @type {number} operating system number. */
- this.os;
- /** @type {number} CRC-16 value for FHCRC flag. */
- this.crc16;
- /** @type {number} extra length. */
- this.xlen;
- /** @type {number} CRC-32 value for verification. */
- this.crc32;
- /** @type {number} input size modulo 32 value. */
- this.isize;
- /** @type {string} filename. */
- this.name;
- /** @type {string} comment. */
- this.comment;
- /** @type {!(Uint8Array|Array.<number>)} */
- this.data;
-};
-
-Zlib.GunzipMember.prototype.getName = function() {
- return this.name;
-};
-
-Zlib.GunzipMember.prototype.getData = function() {
- return this.data;
-};
-
-Zlib.GunzipMember.prototype.getMtime = function() {
- return this.mtime;
-}
-
-});
\ No newline at end of file
+++ /dev/null
-/**
- * @fileoverview GZIP (RFC1952) 実装.
- */
-goog.provide('Zlib.Gzip');
-
-goog.require('USE_TYPEDARRAY');
-goog.require('Zlib.CRC32');
-goog.require('Zlib.RawDeflate');
-
-goog.scope(function() {
-
-/**
- * @constructor
- * @param {!(Array|Uint8Array)} input input buffer.
- * @param {Object=} opt_params option parameters.
- */
-Zlib.Gzip = function(input, opt_params) {
- /** @type {!(Array.<number>|Uint8Array)} input buffer. */
- this.input = input;
- /** @type {number} input buffer pointer. */
- this.ip = 0;
- /** @type {!(Array.<number>|Uint8Array)} output buffer. */
- this.output;
- /** @type {number} output buffer. */
- this.op = 0;
- /** @type {!Object} flags option flags. */
- this.flags = {};
- /** @type {!string} filename. */
- this.filename;
- /** @type {!string} comment. */
- this.comment;
- /** @type {!Object} deflate options. */
- this.deflateOptions;
-
- // option parameters
- if (opt_params) {
- if (opt_params['flags']) {
- this.flags = opt_params['flags'];
- }
- if (typeof opt_params['filename'] === 'string') {
- this.filename = opt_params['filename'];
- }
- if (typeof opt_params['comment'] === 'string') {
- this.comment = opt_params['comment'];
- }
- if (opt_params['deflateOptions']) {
- this.deflateOptions = opt_params['deflateOptions'];
- }
- }
-
- if (!this.deflateOptions) {
- this.deflateOptions = {};
- }
-};
-
-/**
- * @type {number}
- * @const
- */
-Zlib.Gzip.DefaultBufferSize = 0x8000;
-
-/**
- * encode gzip members.
- * @return {!(Array|Uint8Array)} gzip binary array.
- */
-Zlib.Gzip.prototype.compress = function() {
- /** @type {number} flags. */
- var flg;
- /** @type {number} modification time. */
- var mtime;
- /** @type {number} CRC-16 value for FHCRC flag. */
- var crc16;
- /** @type {number} CRC-32 value for verification. */
- var crc32;
- /** @type {!Zlib.RawDeflate} raw deflate object. */
- var rawdeflate;
- /** @type {number} character code */
- var c;
- /** @type {number} loop counter. */
- var i;
- /** @type {number} loop limiter. */
- var il;
- /** @type {!(Array|Uint8Array)} output buffer. */
- var output =
- new (USE_TYPEDARRAY ? Uint8Array : Array)(Zlib.Gzip.DefaultBufferSize);
- /** @type {number} output buffer pointer. */
- var op = 0;
-
- var input = this.input;
- var ip = this.ip;
- var filename = this.filename;
- var comment = this.comment;
-
- // check signature
- output[op++] = 0x1f;
- output[op++] = 0x8b;
-
- // check compression method
- output[op++] = 8; /* XXX: use Zlib const */
-
- // flags
- flg = 0;
- if (this.flags['fname']) flg |= Zlib.Gzip.FlagsMask.FNAME;
- if (this.flags['fcomment']) flg |= Zlib.Gzip.FlagsMask.FCOMMENT;
- if (this.flags['fhcrc']) flg |= Zlib.Gzip.FlagsMask.FHCRC;
- // XXX: FTEXT
- // XXX: FEXTRA
- output[op++] = flg;
-
- // modification time
- mtime = (Date.now ? Date.now() : +new Date()) / 1000 | 0;
- output[op++] = mtime & 0xff;
- output[op++] = mtime >>> 8 & 0xff;
- output[op++] = mtime >>> 16 & 0xff;
- output[op++] = mtime >>> 24 & 0xff;
-
- // extra flags
- output[op++] = 0;
-
- // operating system
- output[op++] = Zlib.Gzip.OperatingSystem.UNKNOWN;
-
- // extra
- /* NOP */
-
- // fname
- if (this.flags['fname'] !== void 0) {
- for (i = 0, il = filename.length; i < il; ++i) {
- c = filename.charCodeAt(i);
- if (c > 0xff) { output[op++] = (c >>> 8) & 0xff; }
- output[op++] = c & 0xff;
- }
- output[op++] = 0; // null termination
- }
-
- // fcomment
- if (this.flags['comment']) {
- for (i = 0, il = comment.length; i < il; ++i) {
- c = comment.charCodeAt(i);
- if (c > 0xff) { output[op++] = (c >>> 8) & 0xff; }
- output[op++] = c & 0xff;
- }
- output[op++] = 0; // null termination
- }
-
- // fhcrc
- if (this.flags['fhcrc']) {
- crc16 = Zlib.CRC32.calc(output, 0, op) & 0xffff;
- output[op++] = (crc16 ) & 0xff;
- output[op++] = (crc16 >>> 8) & 0xff;
- }
-
- // add compress option
- this.deflateOptions['outputBuffer'] = output;
- this.deflateOptions['outputIndex'] = op;
-
- // compress
- rawdeflate = new Zlib.RawDeflate(input, this.deflateOptions);
- output = rawdeflate.compress();
- op = rawdeflate.op;
-
- // expand buffer
- if (USE_TYPEDARRAY) {
- if (op + 8 > output.buffer.byteLength) {
- this.output = new Uint8Array(op + 8);
- this.output.set(new Uint8Array(output.buffer));
- output = this.output;
- } else {
- output = new Uint8Array(output.buffer);
- }
- }
-
- // crc32
- crc32 = Zlib.CRC32.calc(input);
- output[op++] = (crc32 ) & 0xff;
- output[op++] = (crc32 >>> 8) & 0xff;
- output[op++] = (crc32 >>> 16) & 0xff;
- output[op++] = (crc32 >>> 24) & 0xff;
-
- // input size
- il = input.length;
- output[op++] = (il ) & 0xff;
- output[op++] = (il >>> 8) & 0xff;
- output[op++] = (il >>> 16) & 0xff;
- output[op++] = (il >>> 24) & 0xff;
-
- this.ip = ip;
-
- if (USE_TYPEDARRAY && op < output.length) {
- this.output = output = output.subarray(0, op);
- }
-
- return output;
-};
-
-/** @enum {number} */
-Zlib.Gzip.OperatingSystem = {
- FAT: 0,
- AMIGA: 1,
- VMS: 2,
- UNIX: 3,
- VM_CMS: 4,
- ATARI_TOS: 5,
- HPFS: 6,
- MACINTOSH: 7,
- Z_SYSTEM: 8,
- CP_M: 9,
- TOPS_20: 10,
- NTFS: 11,
- QDOS: 12,
- ACORN_RISCOS: 13,
- UNKNOWN: 255
-};
-
-/** @enum {number} */
-Zlib.Gzip.FlagsMask = {
- FTEXT: 0x01,
- FHCRC: 0x02,
- FEXTRA: 0x04,
- FNAME: 0x08,
- FCOMMENT: 0x10
-};
-
-});
-/* vim:set expandtab ts=2 sw=2 tw=80: */
+++ /dev/null
-/**
- * @fileoverview Heap Sort 実装. ハフマン符号化で使用する.
- */
-
-goog.provide('Zlib.Heap');
-
-goog.require('USE_TYPEDARRAY');
-
-goog.scope(function() {
-
-/**
- * カスタムハフマン符号で使用するヒープ実装
- * @param {number} length ヒープサイズ.
- * @constructor
- */
-Zlib.Heap = function(length) {
- this.buffer = new (USE_TYPEDARRAY ? Uint16Array : Array)(length * 2);
- this.length = 0;
-};
-
-/**
- * 親ノードの index 取得
- * @param {number} index 子ノードの index.
- * @return {number} 親ノードの index.
- *
- */
-Zlib.Heap.prototype.getParent = function(index) {
- return ((index - 2) / 4 | 0) * 2;
-};
-
-/**
- * 子ノードの index 取得
- * @param {number} index 親ノードの index.
- * @return {number} 子ノードの index.
- */
-Zlib.Heap.prototype.getChild = function(index) {
- return 2 * index + 2;
-};
-
-/**
- * Heap に値を追加する
- * @param {number} index キー index.
- * @param {number} value 値.
- * @return {number} 現在のヒープ長.
- */
-Zlib.Heap.prototype.push = function(index, value) {
- var current, parent,
- heap = this.buffer,
- swap;
-
- current = this.length;
- heap[this.length++] = value;
- heap[this.length++] = index;
-
- // ルートノードにたどり着くまで入れ替えを試みる
- while (current > 0) {
- parent = this.getParent(current);
-
- // 親ノードと比較して親の方が小さければ入れ替える
- if (heap[current] > heap[parent]) {
- swap = heap[current];
- heap[current] = heap[parent];
- heap[parent] = swap;
-
- swap = heap[current + 1];
- heap[current + 1] = heap[parent + 1];
- heap[parent + 1] = swap;
-
- current = parent;
- // 入れ替えが必要なくなったらそこで抜ける
- } else {
- break;
- }
- }
-
- return this.length;
-};
-
-/**
- * Heapから一番大きい値を返す
- * @return {{index: number, value: number, length: number}} {index: キーindex,
- * value: 値, length: ヒープ長} の Object.
- */
-Zlib.Heap.prototype.pop = function() {
- var index, value,
- heap = this.buffer, swap,
- current, parent;
-
- value = heap[0];
- index = heap[1];
-
- // 後ろから値を取る
- this.length -= 2;
- heap[0] = heap[this.length];
- heap[1] = heap[this.length + 1];
-
- parent = 0;
- // ルートノードから下がっていく
- while (true) {
- current = this.getChild(parent);
-
- // 範囲チェック
- if (current >= this.length) {
- break;
- }
-
- // 隣のノードと比較して、隣の方が値が大きければ隣を現在ノードとして選択
- if (current + 2 < this.length && heap[current + 2] > heap[current]) {
- current += 2;
- }
-
- // 親ノードと比較して親の方が小さい場合は入れ替える
- if (heap[current] > heap[parent]) {
- swap = heap[parent];
- heap[parent] = heap[current];
- heap[current] = swap;
-
- swap = heap[parent + 1];
- heap[parent + 1] = heap[current + 1];
- heap[current + 1] = swap;
- } else {
- break;
- }
-
- parent = current;
- }
-
- return {index: index, value: value, length: this.length};
-};
-
-
-// end of scope
-});
-
-/* vim:set expandtab ts=2 sw=2 tw=80: */
+++ /dev/null
-goog.provide('Zlib.Huffman');
-
-goog.require('USE_TYPEDARRAY');
-
-goog.scope(function() {
-
-/**
- * build huffman table from length list.
- * @param {!(Array.<number>|Uint8Array)} lengths length list.
- * @return {!Array} huffman table.
- */
-Zlib.Huffman.buildHuffmanTable = function(lengths) {
- /** @type {number} length list size. */
- var listSize = lengths.length;
- /** @type {number} max code length for table size. */
- var maxCodeLength = 0;
- /** @type {number} min code length for table size. */
- var minCodeLength = Number.POSITIVE_INFINITY;
- /** @type {number} table size. */
- var size;
- /** @type {!(Array|Uint8Array)} huffman code table. */
- var table;
- /** @type {number} bit length. */
- var bitLength;
- /** @type {number} huffman code. */
- var code;
- /**
- * サイズが 2^maxlength 個のテーブルを埋めるためのスキップ長.
- * @type {number} skip length for table filling.
- */
- var skip;
- /** @type {number} reversed code. */
- var reversed;
- /** @type {number} reverse temp. */
- var rtemp;
- /** @type {number} loop counter. */
- var i;
- /** @type {number} loop limit. */
- var il;
- /** @type {number} loop counter. */
- var j;
- /** @type {number} loop limit. */
- var jl;
-
- // Math.max は遅いので最長の値は for-loop で取得する
- for (i = 0, il = listSize; i < il; ++i) {
- if (lengths[i] > maxCodeLength) {
- maxCodeLength = lengths[i];
- }
- if (lengths[i] < minCodeLength) {
- minCodeLength = lengths[i];
- }
- }
-
- size = 1 << maxCodeLength;
- table = new (USE_TYPEDARRAY ? Uint32Array : Array)(size);
-
- // ビット長の短い順からハフマン符号を割り当てる
- for (bitLength = 1, code = 0, skip = 2; bitLength <= maxCodeLength;) {
- for (i = 0; i < listSize; ++i) {
- if (lengths[i] === bitLength) {
- // ビットオーダーが逆になるためビット長分並びを反転する
- for (reversed = 0, rtemp = code, j = 0; j < bitLength; ++j) {
- reversed = (reversed << 1) | (rtemp & 1);
- rtemp >>= 1;
- }
-
- // 最大ビット長をもとにテーブルを作るため、
- // 最大ビット長以外では 0 / 1 どちらでも良い箇所ができる
- // そのどちらでも良い場所は同じ値で埋めることで
- // 本来のビット長以上のビット数取得しても問題が起こらないようにする
- for (j = reversed; j < size; j += skip) {
- table[j] = (bitLength << 16) | i;
- }
-
- ++code;
- }
- }
-
- // 次のビット長へ
- ++bitLength;
- code <<= 1;
- skip <<= 1;
- }
-
- return [table, maxCodeLength, minCodeLength];
-};
-
-
-// end of scope
-});
-
-/* vim:set expandtab ts=2 sw=2 tw=80: */
+++ /dev/null
-goog.provide('Zlib.Inflate');
-
-goog.require('USE_TYPEDARRAY');
-goog.require('Zlib.Adler32');
-goog.require('Zlib.RawInflate');
-
-goog.scope(function() {
-
-/**
- * @constructor
- * @param {!(Uint8Array|Array)} input deflated buffer.
- * @param {Object=} opt_params option parameters.
- *
- * opt_params は以下のプロパティを指定する事ができます。
- * - index: input buffer の deflate コンテナの開始位置.
- * - blockSize: バッファのブロックサイズ.
- * - verify: 伸張が終わった後 adler-32 checksum の検証を行うか.
- * - bufferType: Zlib.Inflate.BufferType の値によってバッファの管理方法を指定する.
- * Zlib.Inflate.BufferType は Zlib.RawInflate.BufferType のエイリアス.
- */
-Zlib.Inflate = function(input, opt_params) {
- /** @type {number} */
- var bufferSize;
- /** @type {Zlib.Inflate.BufferType} */
- var bufferType;
- /** @type {number} */
- var cmf;
- /** @type {number} */
- var flg;
-
- /** @type {!(Uint8Array|Array)} */
- this.input = input;
- /** @type {number} */
- this.ip = 0;
- /** @type {Zlib.RawInflate} */
- this.rawinflate;
- /** @type {(boolean|undefined)} verify flag. */
- this.verify;
-
- // option parameters
- if (opt_params || !(opt_params = {})) {
- if (opt_params['index']) {
- this.ip = opt_params['index'];
- }
- if (opt_params['verify']) {
- this.verify = opt_params['verify'];
- }
- }
-
- // Compression Method and Flags
- cmf = input[this.ip++];
- flg = input[this.ip++];
-
- // compression method
- switch (cmf & 0x0f) {
- case Zlib.CompressionMethod.DEFLATE:
- this.method = Zlib.CompressionMethod.DEFLATE;
- break;
- default:
- throw new Error('unsupported compression method');
- }
-
- // fcheck
- if (((cmf << 8) + flg) % 31 !== 0) {
- throw new Error('invalid fcheck flag:' + ((cmf << 8) + flg) % 31);
- }
-
- // fdict (not supported)
- if (flg & 0x20) {
- throw new Error('fdict flag is not supported');
- }
-
- // RawInflate
- this.rawinflate = new Zlib.RawInflate(input, {
- 'index': this.ip,
- 'bufferSize': opt_params['bufferSize'],
- 'bufferType': opt_params['bufferType'],
- 'resize': opt_params['resize']
- });
-}
-
-/**
- * @enum {number}
- */
-Zlib.Inflate.BufferType = Zlib.RawInflate.BufferType;
-
-/**
- * decompress.
- * @return {!(Uint8Array|Array)} inflated buffer.
- */
-Zlib.Inflate.prototype.decompress = function() {
- /** @type {!(Array|Uint8Array)} input buffer. */
- var input = this.input;
- /** @type {!(Uint8Array|Array)} inflated buffer. */
- var buffer;
- /** @type {number} adler-32 checksum */
- var adler32;
-
- buffer = this.rawinflate.decompress();
- this.ip = this.rawinflate.ip;
-
- // verify adler-32
- if (this.verify) {
- adler32 = (
- input[this.ip++] << 24 | input[this.ip++] << 16 |
- input[this.ip++] << 8 | input[this.ip++]
- ) >>> 0;
-
- if (adler32 !== Zlib.Adler32(buffer)) {
- throw new Error('invalid adler-32 checksum');
- }
- }
-
- return buffer;
-};
-
-// end of scope
-});
-
-/* vim:set expandtab ts=2 sw=2 tw=80: */
+++ /dev/null
-goog.provide('Zlib.InflateStream');
-
-goog.require('USE_TYPEDARRAY');
-goog.require('Zlib');
-//goog.require('Zlib.Adler32');
-goog.require('Zlib.RawInflateStream');
-
-goog.scope(function() {
-
-/**
- * @param {!(Uint8Array|Array)} input deflated buffer.
- * @constructor
- */
-Zlib.InflateStream = function(input) {
- /** @type {!(Uint8Array|Array)} */
- this.input = input === void 0 ? new (USE_TYPEDARRAY ? Uint8Array : Array)() : input;
- /** @type {number} */
- this.ip = 0;
- /** @type {Zlib.RawInflateStream} */
- this.rawinflate = new Zlib.RawInflateStream(this.input, this.ip);
- /** @type {Zlib.CompressionMethod} */
- this.method;
- /** @type {!(Array|Uint8Array)} */
- this.output = this.rawinflate.output;
-};
-
-/**
- * decompress.
- * @return {!(Uint8Array|Array)} inflated buffer.
- */
-Zlib.InflateStream.prototype.decompress = function(input) {
- /** @type {!(Uint8Array|Array)} inflated buffer. */
- var buffer;
- /** @type {number} adler-32 checksum */
- var adler32;
-
- // 新しい入力を入力バッファに結合する
- // XXX Array, Uint8Array のチェックを行うか確認する
- if (input !== void 0) {
- if (USE_TYPEDARRAY) {
- var tmp = new Uint8Array(this.input.length + input.length);
- tmp.set(this.input, 0);
- tmp.set(input, this.input.length);
- this.input = tmp;
- } else {
- this.input = this.input.concat(input);
- }
- }
-
- if (this.method === void 0) {
- if(this.readHeader() < 0) {
- return new (USE_TYPEDARRAY ? Uint8Array : Array)();
- }
- }
-
- buffer = this.rawinflate.decompress(this.input, this.ip);
- this.ip = this.rawinflate.ip;
-
- // verify adler-32
- /*
- if (this.verify) {
- adler32 =
- input[this.ip++] << 24 | input[this.ip++] << 16 |
- input[this.ip++] << 8 | input[this.ip++];
-
- if (adler32 !== Zlib.Adler32(buffer)) {
- throw new Error('invalid adler-32 checksum');
- }
- }
- */
-
- return buffer;
-};
-
-/**
- * @return {!(Uint8Array|Array)} current output buffer.
- */
-Zlib.InflateStream.prototype.getBytes = function() {
- return this.rawinflate.getBytes();
-};
-
-Zlib.InflateStream.prototype.readHeader = function() {
- var ip = this.ip;
- var input = this.input;
-
- // Compression Method and Flags
- var cmf = input[ip++];
- var flg = input[ip++];
-
- if (cmf === void 0 || flg === void 0) {
- return -1;
- }
-
- // compression method
- switch (cmf & 0x0f) {
- case Zlib.CompressionMethod.DEFLATE:
- this.method = Zlib.CompressionMethod.DEFLATE;
- break;
- default:
- throw new Error('unsupported compression method');
- }
-
- // fcheck
- if (((cmf << 8) + flg) % 31 !== 0) {
- throw new Error('invalid fcheck flag:' + ((cmf << 8) + flg) % 31);
- }
-
- // fdict (not supported)
- if (flg & 0x20) {
- throw new Error('fdict flag is not supported');
- }
-
- this.ip = ip;
-};
-
-// end of scope
-});
-
-/* vim:set expandtab ts=2 sw=2 tw=80: */
+++ /dev/null
-/**
- * @fileoverview Deflate (RFC1951) 符号化アルゴリズム実装.
- */
-
-goog.provide('Zlib.RawDeflate');
-
-goog.require('USE_TYPEDARRAY');
-goog.require('Zlib.BitStream');
-goog.require('Zlib.Heap');
-
-goog.scope(function() {
-
-/**
- * Raw Deflate 実装
- *
- * @constructor
- * @param {!(Array.<number>|Uint8Array)} input 符号化する対象のバッファ.
- * @param {Object=} opt_params option parameters.
- *
- * typed array が使用可能なとき、outputBuffer が Array は自動的に Uint8Array に
- * 変換されます.
- * 別のオブジェクトになるため出力バッファを参照している変数などは
- * 更新する必要があります.
- */
-Zlib.RawDeflate = function(input, opt_params) {
- /** @type {Zlib.RawDeflate.CompressionType} */
- this.compressionType = Zlib.RawDeflate.CompressionType.DYNAMIC;
- /** @type {number} */
- this.lazy = 0;
- /** @type {!(Array.<number>|Uint32Array)} */
- this.freqsLitLen;
- /** @type {!(Array.<number>|Uint32Array)} */
- this.freqsDist;
- /** @type {!(Array.<number>|Uint8Array)} */
- this.input =
- (USE_TYPEDARRAY && input instanceof Array) ? new Uint8Array(input) : input;
- /** @type {!(Array.<number>|Uint8Array)} output output buffer. */
- this.output;
- /** @type {number} pos output buffer position. */
- this.op = 0;
-
- // option parameters
- if (opt_params) {
- if (opt_params['lazy']) {
- this.lazy = opt_params['lazy'];
- }
- if (typeof opt_params['compressionType'] === 'number') {
- this.compressionType = opt_params['compressionType'];
- }
- if (opt_params['outputBuffer']) {
- this.output =
- (USE_TYPEDARRAY && opt_params['outputBuffer'] instanceof Array) ?
- new Uint8Array(opt_params['outputBuffer']) : opt_params['outputBuffer'];
- }
- if (typeof opt_params['outputIndex'] === 'number') {
- this.op = opt_params['outputIndex'];
- }
- }
-
- if (!this.output) {
- this.output = new (USE_TYPEDARRAY ? Uint8Array : Array)(0x8000);
- }
-};
-
-/**
- * @enum {number}
- */
-Zlib.RawDeflate.CompressionType = {
- NONE: 0,
- FIXED: 1,
- DYNAMIC: 2,
- RESERVED: 3
-};
-
-
-/**
- * LZ77 の最小マッチ長
- * @const
- * @type {number}
- */
-Zlib.RawDeflate.Lz77MinLength = 3;
-
-/**
- * LZ77 の最大マッチ長
- * @const
- * @type {number}
- */
-Zlib.RawDeflate.Lz77MaxLength = 258;
-
-/**
- * LZ77 のウィンドウサイズ
- * @const
- * @type {number}
- */
-Zlib.RawDeflate.WindowSize = 0x8000;
-
-/**
- * 最長の符号長
- * @const
- * @type {number}
- */
-Zlib.RawDeflate.MaxCodeLength = 16;
-
-/**
- * ハフマン符号の最大数値
- * @const
- * @type {number}
- */
-Zlib.RawDeflate.HUFMAX = 286;
-
-/**
- * 固定ハフマン符号の符号化テーブル
- * @const
- * @type {Array.<Array.<number, number>>}
- */
-Zlib.RawDeflate.FixedHuffmanTable = (function() {
- var table = [], i;
-
- for (i = 0; i < 288; i++) {
- switch (true) {
- case (i <= 143): table.push([i + 0x030, 8]); break;
- case (i <= 255): table.push([i - 144 + 0x190, 9]); break;
- case (i <= 279): table.push([i - 256 + 0x000, 7]); break;
- case (i <= 287): table.push([i - 280 + 0x0C0, 8]); break;
- default:
- throw 'invalid literal: ' + i;
- }
- }
-
- return table;
-})();
-
-/**
- * DEFLATE ブロックの作成
- * @return {!(Array.<number>|Uint8Array)} 圧縮済み byte array.
- */
-Zlib.RawDeflate.prototype.compress = function() {
- /** @type {!(Array.<number>|Uint8Array)} */
- var blockArray;
- /** @type {number} */
- var position;
- /** @type {number} */
- var length;
-
- var input = this.input;
-
- // compression
- switch (this.compressionType) {
- case Zlib.RawDeflate.CompressionType.NONE:
- // each 65535-Byte (length header: 16-bit)
- for (position = 0, length = input.length; position < length;) {
- blockArray = USE_TYPEDARRAY ?
- input.subarray(position, position + 0xffff) :
- input.slice(position, position + 0xffff);
- position += blockArray.length;
- this.makeNocompressBlock(blockArray, (position === length));
- }
- break;
- case Zlib.RawDeflate.CompressionType.FIXED:
- this.output = this.makeFixedHuffmanBlock(input, true);
- this.op = this.output.length;
- break;
- case Zlib.RawDeflate.CompressionType.DYNAMIC:
- this.output = this.makeDynamicHuffmanBlock(input, true);
- this.op = this.output.length;
- break;
- default:
- throw 'invalid compression type';
- }
-
- return this.output;
-};
-
-/**
- * 非圧縮ブロックの作成
- * @param {!(Array.<number>|Uint8Array)} blockArray ブロックデータ byte array.
- * @param {!boolean} isFinalBlock 最後のブロックならばtrue.
- * @return {!(Array.<number>|Uint8Array)} 非圧縮ブロック byte array.
- */
-Zlib.RawDeflate.prototype.makeNocompressBlock =
-function(blockArray, isFinalBlock) {
- /** @type {number} */
- var bfinal;
- /** @type {Zlib.RawDeflate.CompressionType} */
- var btype;
- /** @type {number} */
- var len;
- /** @type {number} */
- var nlen;
- /** @type {number} */
- var i;
- /** @type {number} */
- var il;
-
- var output = this.output;
- var op = this.op;
-
- // expand buffer
- if (USE_TYPEDARRAY) {
- output = new Uint8Array(this.output.buffer);
- while (output.length <= op + blockArray.length + 5) {
- output = new Uint8Array(output.length << 1);
- }
- output.set(this.output);
- }
-
- // header
- bfinal = isFinalBlock ? 1 : 0;
- btype = Zlib.RawDeflate.CompressionType.NONE;
- output[op++] = (bfinal) | (btype << 1);
-
- // length
- len = blockArray.length;
- nlen = (~len + 0x10000) & 0xffff;
- output[op++] = len & 0xff;
- output[op++] = (len >>> 8) & 0xff;
- output[op++] = nlen & 0xff;
- output[op++] = (nlen >>> 8) & 0xff;
-
- // copy buffer
- if (USE_TYPEDARRAY) {
- output.set(blockArray, op);
- op += blockArray.length;
- output = output.subarray(0, op);
- } else {
- for (i = 0, il = blockArray.length; i < il; ++i) {
- output[op++] = blockArray[i];
- }
- output.length = op;
- }
-
- this.op = op;
- this.output = output;
-
- return output;
-};
-
-/**
- * 固定ハフマンブロックの作成
- * @param {!(Array.<number>|Uint8Array)} blockArray ブロックデータ byte array.
- * @param {!boolean} isFinalBlock 最後のブロックならばtrue.
- * @return {!(Array.<number>|Uint8Array)} 固定ハフマン符号化ブロック byte array.
- */
-Zlib.RawDeflate.prototype.makeFixedHuffmanBlock =
-function(blockArray, isFinalBlock) {
- /** @type {Zlib.BitStream} */
- var stream = new Zlib.BitStream(USE_TYPEDARRAY ?
- new Uint8Array(this.output.buffer) : this.output, this.op);
- /** @type {number} */
- var bfinal;
- /** @type {Zlib.RawDeflate.CompressionType} */
- var btype;
- /** @type {!(Array.<number>|Uint16Array)} */
- var data;
-
- // header
- bfinal = isFinalBlock ? 1 : 0;
- btype = Zlib.RawDeflate.CompressionType.FIXED;
-
- stream.writeBits(bfinal, 1, true);
- stream.writeBits(btype, 2, true);
-
- data = this.lz77(blockArray);
- this.fixedHuffman(data, stream);
-
- return stream.finish();
-};
-
-/**
- * 動的ハフマンブロックの作成
- * @param {!(Array.<number>|Uint8Array)} blockArray ブロックデータ byte array.
- * @param {!boolean} isFinalBlock 最後のブロックならばtrue.
- * @return {!(Array.<number>|Uint8Array)} 動的ハフマン符号ブロック byte array.
- */
-Zlib.RawDeflate.prototype.makeDynamicHuffmanBlock =
-function(blockArray, isFinalBlock) {
- /** @type {Zlib.BitStream} */
- var stream = new Zlib.BitStream(USE_TYPEDARRAY ?
- new Uint8Array(this.output.buffer) : this.output, this.op);
- /** @type {number} */
- var bfinal;
- /** @type {Zlib.RawDeflate.CompressionType} */
- var btype;
- /** @type {!(Array.<number>|Uint16Array)} */
- var data;
- /** @type {number} */
- var hlit;
- /** @type {number} */
- var hdist;
- /** @type {number} */
- var hclen;
- /** @const @type {Array.<number>} */
- var hclenOrder =
- [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15];
- /** @type {!(Array.<number>|Uint8Array)} */
- var litLenLengths;
- /** @type {!(Array.<number>|Uint16Array)} */
- var litLenCodes;
- /** @type {!(Array.<number>|Uint8Array)} */
- var distLengths;
- /** @type {!(Array.<number>|Uint16Array)} */
- var distCodes;
- /** @type {{
- * codes: !(Array.<number>|Uint32Array),
- * freqs: !(Array.<number>|Uint32Array)
- * }} */
- var treeSymbols;
- /** @type {!(Array.<number>|Uint8Array)} */
- var treeLengths;
- /** @type {Array} */
- var transLengths = new Array(19);
- /** @type {!(Array.<number>|Uint16Array)} */
- var treeCodes;
- /** @type {number} */
- var code;
- /** @type {number} */
- var bitlen;
- /** @type {number} */
- var i;
- /** @type {number} */
- var il;
-
- // header
- bfinal = isFinalBlock ? 1 : 0;
- btype = Zlib.RawDeflate.CompressionType.DYNAMIC;
-
- stream.writeBits(bfinal, 1, true);
- stream.writeBits(btype, 2, true);
-
- data = this.lz77(blockArray);
-
- // リテラル・長さ, 距離のハフマン符号と符号長の算出
- litLenLengths = this.getLengths_(this.freqsLitLen, 15);
- litLenCodes = this.getCodesFromLengths_(litLenLengths);
- distLengths = this.getLengths_(this.freqsDist, 7);
- distCodes = this.getCodesFromLengths_(distLengths);
-
- // HLIT, HDIST の決定
- for (hlit = 286; hlit > 257 && litLenLengths[hlit - 1] === 0; hlit--) {}
- for (hdist = 30; hdist > 1 && distLengths[hdist - 1] === 0; hdist--) {}
-
- // HCLEN
- treeSymbols =
- this.getTreeSymbols_(hlit, litLenLengths, hdist, distLengths);
- treeLengths = this.getLengths_(treeSymbols.freqs, 7);
- for (i = 0; i < 19; i++) {
- transLengths[i] = treeLengths[hclenOrder[i]];
- }
- for (hclen = 19; hclen > 4 && transLengths[hclen - 1] === 0; hclen--) {}
-
- treeCodes = this.getCodesFromLengths_(treeLengths);
-
- // 出力
- stream.writeBits(hlit - 257, 5, true);
- stream.writeBits(hdist - 1, 5, true);
- stream.writeBits(hclen - 4, 4, true);
- for (i = 0; i < hclen; i++) {
- stream.writeBits(transLengths[i], 3, true);
- }
-
- // ツリーの出力
- for (i = 0, il = treeSymbols.codes.length; i < il; i++) {
- code = treeSymbols.codes[i];
-
- stream.writeBits(treeCodes[code], treeLengths[code], true);
-
- // extra bits
- if (code >= 16) {
- i++;
- switch (code) {
- case 16: bitlen = 2; break;
- case 17: bitlen = 3; break;
- case 18: bitlen = 7; break;
- default:
- throw 'invalid code: ' + code;
- }
-
- stream.writeBits(treeSymbols.codes[i], bitlen, true);
- }
- }
-
- this.dynamicHuffman(
- data,
- [litLenCodes, litLenLengths],
- [distCodes, distLengths],
- stream
- );
-
- return stream.finish();
-};
-
-
-/**
- * 動的ハフマン符号化(カスタムハフマンテーブル)
- * @param {!(Array.<number>|Uint16Array)} dataArray LZ77 符号化済み byte array.
- * @param {!Zlib.BitStream} stream 書き込み用ビットストリーム.
- * @return {!Zlib.BitStream} ハフマン符号化済みビットストリームオブジェクト.
- */
-Zlib.RawDeflate.prototype.dynamicHuffman =
-function(dataArray, litLen, dist, stream) {
- /** @type {number} */
- var index;
- /** @type {number} */
- var length;
- /** @type {number} */
- var literal;
- /** @type {number} */
- var code;
- /** @type {number} */
- var litLenCodes;
- /** @type {number} */
- var litLenLengths;
- /** @type {number} */
- var distCodes;
- /** @type {number} */
- var distLengths;
-
- litLenCodes = litLen[0];
- litLenLengths = litLen[1];
- distCodes = dist[0];
- distLengths = dist[1];
-
- // 符号を BitStream に書き込んでいく
- for (index = 0, length = dataArray.length; index < length; ++index) {
- literal = dataArray[index];
-
- // literal or length
- stream.writeBits(litLenCodes[literal], litLenLengths[literal], true);
-
- // 長さ・距離符号
- if (literal > 256) {
- // length extra
- stream.writeBits(dataArray[++index], dataArray[++index], true);
- // distance
- code = dataArray[++index];
- stream.writeBits(distCodes[code], distLengths[code], true);
- // distance extra
- stream.writeBits(dataArray[++index], dataArray[++index], true);
- // 終端
- } else if (literal === 256) {
- break;
- }
- }
-
- return stream;
-};
-
-/**
- * 固定ハフマン符号化
- * @param {!(Array.<number>|Uint16Array)} dataArray LZ77 符号化済み byte array.
- * @param {!Zlib.BitStream} stream 書き込み用ビットストリーム.
- * @return {!Zlib.BitStream} ハフマン符号化済みビットストリームオブジェクト.
- */
-Zlib.RawDeflate.prototype.fixedHuffman = function(dataArray, stream) {
- /** @type {number} */
- var index;
- /** @type {number} */
- var length;
- /** @type {number} */
- var literal;
-
- // 符号を BitStream に書き込んでいく
- for (index = 0, length = dataArray.length; index < length; index++) {
- literal = dataArray[index];
-
- // 符号の書き込み
- Zlib.BitStream.prototype.writeBits.apply(
- stream,
- Zlib.RawDeflate.FixedHuffmanTable[literal]
- );
-
- // 長さ・距離符号
- if (literal > 0x100) {
- // length extra
- stream.writeBits(dataArray[++index], dataArray[++index], true);
- // distance
- stream.writeBits(dataArray[++index], 5);
- // distance extra
- stream.writeBits(dataArray[++index], dataArray[++index], true);
- // 終端
- } else if (literal === 0x100) {
- break;
- }
- }
-
- return stream;
-};
-
-/**
- * マッチ情報
- * @param {!number} length マッチした長さ.
- * @param {!number} backwardDistance マッチ位置との距離.
- * @constructor
- */
-Zlib.RawDeflate.Lz77Match = function(length, backwardDistance) {
- /** @type {number} match length. */
- this.length = length;
- /** @type {number} backward distance. */
- this.backwardDistance = backwardDistance;
-};
-
-/**
- * 長さ符号テーブル.
- * [コード, 拡張ビット, 拡張ビット長] の配列となっている.
- * @const
- * @type {!(Array.<number>|Uint32Array)}
- */
-Zlib.RawDeflate.Lz77Match.LengthCodeTable = (function(table) {
- return USE_TYPEDARRAY ? new Uint32Array(table) : table;
-})((function() {
- /** @type {!Array} */
- var table = [];
- /** @type {number} */
- var i;
- /** @type {!Array.<number>} */
- var c;
-
- for (i = 3; i <= 258; i++) {
- c = code(i);
- table[i] = (c[2] << 24) | (c[1] << 16) | c[0];
- }
-
- /**
- * @param {number} length lz77 length.
- * @return {!Array.<number>} lz77 codes.
- */
- function code(length) {
- switch (true) {
- case (length === 3): return [257, length - 3, 0]; break;
- case (length === 4): return [258, length - 4, 0]; break;
- case (length === 5): return [259, length - 5, 0]; break;
- case (length === 6): return [260, length - 6, 0]; break;
- case (length === 7): return [261, length - 7, 0]; break;
- case (length === 8): return [262, length - 8, 0]; break;
- case (length === 9): return [263, length - 9, 0]; break;
- case (length === 10): return [264, length - 10, 0]; break;
- case (length <= 12): return [265, length - 11, 1]; break;
- case (length <= 14): return [266, length - 13, 1]; break;
- case (length <= 16): return [267, length - 15, 1]; break;
- case (length <= 18): return [268, length - 17, 1]; break;
- case (length <= 22): return [269, length - 19, 2]; break;
- case (length <= 26): return [270, length - 23, 2]; break;
- case (length <= 30): return [271, length - 27, 2]; break;
- case (length <= 34): return [272, length - 31, 2]; break;
- case (length <= 42): return [273, length - 35, 3]; break;
- case (length <= 50): return [274, length - 43, 3]; break;
- case (length <= 58): return [275, length - 51, 3]; break;
- case (length <= 66): return [276, length - 59, 3]; break;
- case (length <= 82): return [277, length - 67, 4]; break;
- case (length <= 98): return [278, length - 83, 4]; break;
- case (length <= 114): return [279, length - 99, 4]; break;
- case (length <= 130): return [280, length - 115, 4]; break;
- case (length <= 162): return [281, length - 131, 5]; break;
- case (length <= 194): return [282, length - 163, 5]; break;
- case (length <= 226): return [283, length - 195, 5]; break;
- case (length <= 257): return [284, length - 227, 5]; break;
- case (length === 258): return [285, length - 258, 0]; break;
- default: throw 'invalid length: ' + length;
- }
- };
-
- return table;
-})());
-
-/**
- * 距離符号テーブル
- * @param {!number} dist 距離.
- * @return {!Array.<number>} コード、拡張ビット、拡張ビット長の配列.
- * @private
- */
-Zlib.RawDeflate.Lz77Match.prototype.getDistanceCode_ = function(dist) {
- /** @type {!Array.<number>} distance code table. */
- var r;
-
- switch (true) {
- case (dist === 1): r = [0, dist - 1, 0]; break;
- case (dist === 2): r = [1, dist - 2, 0]; break;
- case (dist === 3): r = [2, dist - 3, 0]; break;
- case (dist === 4): r = [3, dist - 4, 0]; break;
- case (dist <= 6): r = [4, dist - 5, 1]; break;
- case (dist <= 8): r = [5, dist - 7, 1]; break;
- case (dist <= 12): r = [6, dist - 9, 2]; break;
- case (dist <= 16): r = [7, dist - 13, 2]; break;
- case (dist <= 24): r = [8, dist - 17, 3]; break;
- case (dist <= 32): r = [9, dist - 25, 3]; break;
- case (dist <= 48): r = [10, dist - 33, 4]; break;
- case (dist <= 64): r = [11, dist - 49, 4]; break;
- case (dist <= 96): r = [12, dist - 65, 5]; break;
- case (dist <= 128): r = [13, dist - 97, 5]; break;
- case (dist <= 192): r = [14, dist - 129, 6]; break;
- case (dist <= 256): r = [15, dist - 193, 6]; break;
- case (dist <= 384): r = [16, dist - 257, 7]; break;
- case (dist <= 512): r = [17, dist - 385, 7]; break;
- case (dist <= 768): r = [18, dist - 513, 8]; break;
- case (dist <= 1024): r = [19, dist - 769, 8]; break;
- case (dist <= 1536): r = [20, dist - 1025, 9]; break;
- case (dist <= 2048): r = [21, dist - 1537, 9]; break;
- case (dist <= 3072): r = [22, dist - 2049, 10]; break;
- case (dist <= 4096): r = [23, dist - 3073, 10]; break;
- case (dist <= 6144): r = [24, dist - 4097, 11]; break;
- case (dist <= 8192): r = [25, dist - 6145, 11]; break;
- case (dist <= 12288): r = [26, dist - 8193, 12]; break;
- case (dist <= 16384): r = [27, dist - 12289, 12]; break;
- case (dist <= 24576): r = [28, dist - 16385, 13]; break;
- case (dist <= 32768): r = [29, dist - 24577, 13]; break;
- default: throw 'invalid distance';
- }
-
- return r;
-};
-
-/**
- * マッチ情報を LZ77 符号化配列で返す.
- * なお、ここでは以下の内部仕様で符号化している
- * [ CODE, EXTRA-BIT-LEN, EXTRA, CODE, EXTRA-BIT-LEN, EXTRA ]
- * @return {!Array.<number>} LZ77 符号化 byte array.
- */
-Zlib.RawDeflate.Lz77Match.prototype.toLz77Array = function() {
- /** @type {number} */
- var length = this.length;
- /** @type {number} */
- var dist = this.backwardDistance;
- /** @type {Array} */
- var codeArray = [];
- /** @type {number} */
- var pos = 0;
- /** @type {!Array.<number>} */
- var code;
-
- // length
- code = Zlib.RawDeflate.Lz77Match.LengthCodeTable[length];
- codeArray[pos++] = code & 0xffff;
- codeArray[pos++] = (code >> 16) & 0xff;
- codeArray[pos++] = code >> 24;
-
- // distance
- code = this.getDistanceCode_(dist);
- codeArray[pos++] = code[0];
- codeArray[pos++] = code[1];
- codeArray[pos++] = code[2];
-
- return codeArray;
-};
-
-/**
- * LZ77 実装
- * @param {!(Array.<number>|Uint8Array)} dataArray LZ77 符号化するバイト配列.
- * @return {!(Array.<number>|Uint16Array)} LZ77 符号化した配列.
- */
-Zlib.RawDeflate.prototype.lz77 = function(dataArray) {
- /** @type {number} input position */
- var position;
- /** @type {number} input length */
- var length;
- /** @type {number} loop counter */
- var i;
- /** @type {number} loop limiter */
- var il;
- /** @type {number} chained-hash-table key */
- var matchKey;
- /** @type {Object.<number, Array.<number>>} chained-hash-table */
- var table = {};
- /** @const @type {number} */
- var windowSize = Zlib.RawDeflate.WindowSize;
- /** @type {Array.<number>} match list */
- var matchList;
- /** @type {Zlib.RawDeflate.Lz77Match} longest match */
- var longestMatch;
- /** @type {Zlib.RawDeflate.Lz77Match} previous longest match */
- var prevMatch;
- /** @type {!(Array.<number>|Uint16Array)} lz77 buffer */
- var lz77buf = USE_TYPEDARRAY ?
- new Uint16Array(dataArray.length * 2) : new Array();
- /** @type {number} lz77 output buffer pointer */
- var pos = 0;
- /** @type {number} lz77 skip length */
- var skipLength = 0;
- /** @type {!(Array.<number>|Uint32Array)} */
- var freqsLitLen = new (USE_TYPEDARRAY ? Uint32Array : Array)(286);
- /** @type {!(Array.<number>|Uint32Array)} */
- var freqsDist = new (USE_TYPEDARRAY ? Uint32Array : Array)(30);
- /** @type {number} */
- var lazy = this.lazy;
- /** @type {*} temporary variable */
- var tmp;
-
- // 初期化
- if (!USE_TYPEDARRAY) {
- for (i = 0; i <= 285;) { freqsLitLen[i++] = 0; }
- for (i = 0; i <= 29;) { freqsDist[i++] = 0; }
- }
- freqsLitLen[256] = 1; // EOB の最低出現回数は 1
-
- /**
- * マッチデータの書き込み
- * @param {Zlib.RawDeflate.Lz77Match} match LZ77 Match data.
- * @param {!number} offset スキップ開始位置(相対指定).
- * @private
- */
- function writeMatch(match, offset) {
- /** @type {Array.<number>} */
- var lz77Array = match.toLz77Array();
- /** @type {number} */
- var i;
- /** @type {number} */
- var il;
-
- for (i = 0, il = lz77Array.length; i < il; ++i) {
- lz77buf[pos++] = lz77Array[i];
- }
- freqsLitLen[lz77Array[0]]++;
- freqsDist[lz77Array[3]]++;
- skipLength = match.length + offset - 1;
- prevMatch = null;
- }
-
- // LZ77 符号化
- for (position = 0, length = dataArray.length; position < length; ++position) {
- // ハッシュキーの作成
- for (matchKey = 0, i = 0, il = Zlib.RawDeflate.Lz77MinLength; i < il; ++i) {
- if (position + i === length) {
- break;
- }
- matchKey = (matchKey << 8) | dataArray[position + i];
- }
-
- // テーブルが未定義だったら作成する
- if (table[matchKey] === void 0) { table[matchKey] = []; }
- matchList = table[matchKey];
-
- // skip
- if (skipLength-- > 0) {
- matchList.push(position);
- continue;
- }
-
- // マッチテーブルの更新 (最大戻り距離を超えているものを削除する)
- while (matchList.length > 0 && position - matchList[0] > windowSize) {
- matchList.shift();
- }
-
- // データ末尾でマッチしようがない場合はそのまま流しこむ
- if (position + Zlib.RawDeflate.Lz77MinLength >= length) {
- if (prevMatch) {
- writeMatch(prevMatch, -1);
- }
-
- for (i = 0, il = length - position; i < il; ++i) {
- tmp = dataArray[position + i];
- lz77buf[pos++] = tmp;
- ++freqsLitLen[tmp];
- }
- break;
- }
-
- // マッチ候補から最長のものを探す
- if (matchList.length > 0) {
- longestMatch = this.searchLongestMatch_(dataArray, position, matchList);
-
- if (prevMatch) {
- // 現在のマッチの方が前回のマッチよりも長い
- if (prevMatch.length < longestMatch.length) {
- // write previous literal
- tmp = dataArray[position - 1];
- lz77buf[pos++] = tmp;
- ++freqsLitLen[tmp];
-
- // write current match
- writeMatch(longestMatch, 0);
- } else {
- // write previous match
- writeMatch(prevMatch, -1);
- }
- } else if (longestMatch.length < lazy) {
- prevMatch = longestMatch;
- } else {
- writeMatch(longestMatch, 0);
- }
- // 前回マッチしていて今回マッチがなかったら前回のを採用
- } else if (prevMatch) {
- writeMatch(prevMatch, -1);
- } else {
- tmp = dataArray[position];
- lz77buf[pos++] = tmp;
- ++freqsLitLen[tmp];
- }
-
- matchList.push(position); // マッチテーブルに現在の位置を保存
- }
-
- // 終端処理
- lz77buf[pos++] = 256;
- freqsLitLen[256]++;
- this.freqsLitLen = freqsLitLen;
- this.freqsDist = freqsDist;
-
- return /** @type {!(Uint16Array|Array.<number>)} */ (
- USE_TYPEDARRAY ? lz77buf.subarray(0, pos) : lz77buf
- );
-};
-
-/**
- * マッチした候補の中から最長一致を探す
- * @param {!Object} data plain data byte array.
- * @param {!number} position plain data byte array position.
- * @param {!Array.<number>} matchList 候補となる位置の配列.
- * @return {!Zlib.RawDeflate.Lz77Match} 最長かつ最短距離のマッチオブジェクト.
- * @private
- */
-Zlib.RawDeflate.prototype.searchLongestMatch_ =
-function(data, position, matchList) {
- var match,
- currentMatch,
- matchMax = 0, matchLength,
- i, j, l, dl = data.length;
-
- // 候補を後ろから 1 つずつ絞り込んでゆく
- permatch:
- for (i = 0, l = matchList.length; i < l; i++) {
- match = matchList[l - i - 1];
- matchLength = Zlib.RawDeflate.Lz77MinLength;
-
- // 前回までの最長一致を末尾から一致検索する
- if (matchMax > Zlib.RawDeflate.Lz77MinLength) {
- for (j = matchMax; j > Zlib.RawDeflate.Lz77MinLength; j--) {
- if (data[match + j - 1] !== data[position + j - 1]) {
- continue permatch;
- }
- }
- matchLength = matchMax;
- }
-
- // 最長一致探索
- while (matchLength < Zlib.RawDeflate.Lz77MaxLength &&
- position + matchLength < dl &&
- data[match + matchLength] === data[position + matchLength]) {
- ++matchLength;
- }
-
- // マッチ長が同じ場合は後方を優先
- if (matchLength > matchMax) {
- currentMatch = match;
- matchMax = matchLength;
- }
-
- // 最長が確定したら後の処理は省略
- if (matchLength === Zlib.RawDeflate.Lz77MaxLength) {
- break;
- }
- }
-
- return new Zlib.RawDeflate.Lz77Match(matchMax, position - currentMatch);
-};
-
-/**
- * Tree-Transmit Symbols の算出
- * reference: PuTTY Deflate implementation
- * @param {number} hlit HLIT.
- * @param {!(Array.<number>|Uint8Array)} litlenLengths リテラルと長さ符号の符号長配列.
- * @param {number} hdist HDIST.
- * @param {!(Array.<number>|Uint8Array)} distLengths 距離符号の符号長配列.
- * @return {{
- * codes: !(Array.<number>|Uint32Array),
- * freqs: !(Array.<number>|Uint32Array)
- * }} Tree-Transmit Symbols.
- */
-Zlib.RawDeflate.prototype.getTreeSymbols_ =
-function(hlit, litlenLengths, hdist, distLengths) {
- var src = new (USE_TYPEDARRAY ? Uint32Array : Array)(hlit + hdist),
- i, j, runLength, l, length,
- result = new (USE_TYPEDARRAY ? Uint32Array : Array)(286 + 30),
- nResult,
- rpt,
- freqs = new (USE_TYPEDARRAY ? Uint8Array : Array)(19);
-
- j = 0;
- for (i = 0; i < hlit; i++) {
- src[j++] = litlenLengths[i];
- }
- for (i = 0; i < hdist; i++) {
- src[j++] = distLengths[i];
- }
-
- // 初期化
- if (!USE_TYPEDARRAY) {
- for (i = 0, l = freqs.length; i < l; ++i) {
- freqs[i] = 0;
- }
- }
-
- // 符号化
- nResult = 0;
- for (i = 0, l = src.length; i < l; i += j) {
- // Run Length Encoding
- for (j = 1; i + j < l && src[i + j] === src[i]; ++j) {}
-
- runLength = j;
-
- if (src[i] === 0) {
- // 0 の繰り返しが 3 回未満ならばそのまま
- if (runLength < 3) {
- while (runLength-- > 0) {
- result[nResult++] = 0;
- freqs[0]++;
- }
- } else {
- while (runLength > 0) {
- // 繰り返しは最大 138 までなので切り詰める
- rpt = (runLength < 138 ? runLength : 138);
-
- if (rpt > runLength - 3 && rpt < runLength) {
- rpt = runLength - 3;
- }
-
- // 3-10 回 -> 17
- if (rpt <= 10) {
- result[nResult++] = 17;
- result[nResult++] = rpt - 3;
- freqs[17]++;
- // 11-138 回 -> 18
- } else {
- result[nResult++] = 18;
- result[nResult++] = rpt - 11;
- freqs[18]++;
- }
-
- runLength -= rpt;
- }
- }
- } else {
- result[nResult++] = src[i];
- freqs[src[i]]++;
- runLength--;
-
- // 繰り返し回数が3回未満ならばランレングス符号は要らない
- if (runLength < 3) {
- while (runLength-- > 0) {
- result[nResult++] = src[i];
- freqs[src[i]]++;
- }
- // 3 回以上ならばランレングス符号化
- } else {
- while (runLength > 0) {
- // runLengthを 3-6 で分割
- rpt = (runLength < 6 ? runLength : 6);
-
- if (rpt > runLength - 3 && rpt < runLength) {
- rpt = runLength - 3;
- }
-
- result[nResult++] = 16;
- result[nResult++] = rpt - 3;
- freqs[16]++;
-
- runLength -= rpt;
- }
- }
- }
- }
-
- return {
- codes:
- USE_TYPEDARRAY ? result.subarray(0, nResult) : result.slice(0, nResult),
- freqs: freqs
- };
-};
-
-/**
- * ハフマン符号の長さを取得する
- * @param {!(Array.<number>|Uint32Array)} freqs 出現カウント.
- * @param {number} limit 符号長の制限.
- * @return {!(Array.<number>|Uint8Array)} 符号長配列.
- * @private
- */
-Zlib.RawDeflate.prototype.getLengths_ = function(freqs, limit) {
- /** @type {number} */
- var nSymbols = freqs.length;
- /** @type {Zlib.Heap} */
- var heap = new Zlib.Heap(2 * Zlib.RawDeflate.HUFMAX);
- /** @type {!(Array.<number>|Uint8Array)} */
- var length = new (USE_TYPEDARRAY ? Uint8Array : Array)(nSymbols);
- /** @type {Array} */
- var nodes;
- /** @type {!(Array.<number>|Uint8Array)} */
- var values;
- /** @type {!(Array.<number>|Uint8Array)} */
- var codeLength;
- /** @type {number} */
- var i;
- /** @type {number} */
- var il;
- /** @type {Array.<number>} */
- var freqsZero = [];
-
- // 配列の初期化
- if (!USE_TYPEDARRAY) {
- for (i = 0; i < nSymbols; i++) {
- length[i] = 0;
- }
- }
-
- // ヒープの構築
- for (i = 0; i < nSymbols; ++i) {
- if (freqs[i] > 0) {
- heap.push(i, freqs[i]);
- }
- }
- nodes = new Array(heap.length / 2);
- values = new (USE_TYPEDARRAY ? Uint32Array : Array)(heap.length / 2);
-
- // 非 0 の要素が一つだけだった場合は、そのシンボルに符号長 1 を割り当てて終了
- if (nodes.length === 1) {
- length[heap.pop().index] = 1;
- return length;
- }
-
- // Reverse Package Merge Algorithm による Canonical Huffman Code の符号長決定
- for (i = 0, il = heap.length / 2; i < il; ++i) {
- nodes[i] = heap.pop();
- values[i] = nodes[i].value;
- }
- codeLength = this.reversePackageMerge_(values, values.length, limit);
-
- for (i = 0, il = nodes.length; i < il; ++i) {
- length[nodes[i].index] = codeLength[i];
- }
-
- return length;
-};
-
-/**
- * Reverse Package Merge Algorithm.
- * @param {!(Array.<number>|Uint32Array)} freqs sorted probability.
- * @param {number} symbols number of symbols.
- * @param {number} limit code length limit.
- * @return {!(Array.<number>|Uint8Array)} code lengths.
- */
-Zlib.RawDeflate.prototype.reversePackageMerge_ = function(freqs, symbols, limit) {
- /** @type {!(Array.<number>|Uint16Array)} */
- var minimumCost = new (USE_TYPEDARRAY ? Uint16Array : Array)(limit);
- /** @type {!(Array.<number>|Uint8Array)} */
- var flag = new (USE_TYPEDARRAY ? Uint8Array : Array)(limit);
- /** @type {!(Array.<number>|Uint8Array)} */
- var codeLength = new (USE_TYPEDARRAY ? Uint8Array : Array)(symbols);
- /** @type {Array} */
- var value = new Array(limit);
- /** @type {Array} */
- var type = new Array(limit);
- /** @type {Array.<number>} */
- var currentPosition = new Array(limit);
- /** @type {number} */
- var excess = (1 << limit) - symbols;
- /** @type {number} */
- var half = (1 << (limit - 1));
- /** @type {number} */
- var i;
- /** @type {number} */
- var j;
- /** @type {number} */
- var t;
- /** @type {number} */
- var weight;
- /** @type {number} */
- var next;
-
- /**
- * @param {number} j
- */
- function takePackage(j) {
- /** @type {number} */
- var x = type[j][currentPosition[j]];
-
- if (x === symbols) {
- takePackage(j+1);
- takePackage(j+1);
- } else {
- --codeLength[x];
- }
-
- ++currentPosition[j];
- }
-
- minimumCost[limit-1] = symbols;
-
- for (j = 0; j < limit; ++j) {
- if (excess < half) {
- flag[j] = 0;
- } else {
- flag[j] = 1;
- excess -= half;
- }
- excess <<= 1;
- minimumCost[limit-2-j] = (minimumCost[limit-1-j] / 2 | 0) + symbols;
- }
- minimumCost[0] = flag[0];
-
- value[0] = new Array(minimumCost[0]);
- type[0] = new Array(minimumCost[0]);
- for (j = 1; j < limit; ++j) {
- if (minimumCost[j] > 2 * minimumCost[j-1] + flag[j]) {
- minimumCost[j] = 2 * minimumCost[j-1] + flag[j];
- }
- value[j] = new Array(minimumCost[j]);
- type[j] = new Array(minimumCost[j]);
- }
-
- for (i = 0; i < symbols; ++i) {
- codeLength[i] = limit;
- }
-
- for (t = 0; t < minimumCost[limit-1]; ++t) {
- value[limit-1][t] = freqs[t];
- type[limit-1][t] = t;
- }
-
- for (i = 0; i < limit; ++i) {
- currentPosition[i] = 0;
- }
- if (flag[limit-1] === 1) {
- --codeLength[0];
- ++currentPosition[limit-1];
- }
-
- for (j = limit-2; j >= 0; --j) {
- i = 0;
- weight = 0;
- next = currentPosition[j+1];
-
- for (t = 0; t < minimumCost[j]; t++) {
- weight = value[j+1][next] + value[j+1][next+1];
-
- if (weight > freqs[i]) {
- value[j][t] = weight;
- type[j][t] = symbols;
- next += 2;
- } else {
- value[j][t] = freqs[i];
- type[j][t] = i;
- ++i;
- }
- }
-
- currentPosition[j] = 0;
- if (flag[j] === 1) {
- takePackage(j);
- }
- }
-
- return codeLength;
-};
-
-/**
- * 符号長配列からハフマン符号を取得する
- * reference: PuTTY Deflate implementation
- * @param {!(Array.<number>|Uint8Array)} lengths 符号長配列.
- * @return {!(Array.<number>|Uint16Array)} ハフマン符号配列.
- * @private
- */
-Zlib.RawDeflate.prototype.getCodesFromLengths_ = function(lengths) {
- var codes = new (USE_TYPEDARRAY ? Uint16Array : Array)(lengths.length),
- count = [],
- startCode = [],
- code = 0, i, il, j, m;
-
- // Count the codes of each length.
- for (i = 0, il = lengths.length; i < il; i++) {
- count[lengths[i]] = (count[lengths[i]] | 0) + 1;
- }
-
- // Determine the starting code for each length block.
- for (i = 1, il = Zlib.RawDeflate.MaxCodeLength; i <= il; i++) {
- startCode[i] = code;
- code += count[i] | 0;
- code <<= 1;
- }
-
- // Determine the code for each symbol. Mirrored, of course.
- for (i = 0, il = lengths.length; i < il; i++) {
- code = startCode[lengths[i]];
- startCode[lengths[i]] += 1;
- codes[i] = 0;
-
- for (j = 0, m = lengths[i]; j < m; j++) {
- codes[i] = (codes[i] << 1) | (code & 1);
- code >>>= 1;
- }
- }
-
- return codes;
-};
-
-// end of scope
-});
-
-/* vim:set expandtab ts=2 sw=2 tw=80: */
+++ /dev/null
-goog.provide('Zlib.RawInflate');
-
-goog.require('USE_TYPEDARRAY');
-goog.require('Zlib.Huffman');
-
-//-----------------------------------------------------------------------------
-
-/** @define {number} buffer block size. */
-var ZLIB_RAW_INFLATE_BUFFER_SIZE = 0x8000; // [ 0x8000 >= ZLIB_BUFFER_BLOCK_SIZE ]
-
-//-----------------------------------------------------------------------------
-
-goog.scope(function() {
-
-var buildHuffmanTable = Zlib.Huffman.buildHuffmanTable;
-
-/**
- * @constructor
- * @param {!(Uint8Array|Array.<number>)} input input buffer.
- * @param {Object} opt_params option parameter.
- *
- * opt_params は以下のプロパティを指定する事ができます。
- * - index: input buffer の deflate コンテナの開始位置.
- * - blockSize: バッファのブロックサイズ.
- * - bufferType: Zlib.RawInflate.BufferType の値によってバッファの管理方法を指定する.
- * - resize: 確保したバッファが実際の大きさより大きかった場合に切り詰める.
- */
-Zlib.RawInflate = function(input, opt_params) {
- /** @type {!(Array.<number>|Uint8Array)} inflated buffer */
- this.buffer;
- /** @type {!Array.<(Array.<number>|Uint8Array)>} */
- this.blocks = [];
- /** @type {number} block size. */
- this.bufferSize = ZLIB_RAW_INFLATE_BUFFER_SIZE;
- /** @type {!number} total output buffer pointer. */
- this.totalpos = 0;
- /** @type {!number} input buffer pointer. */
- this.ip = 0;
- /** @type {!number} bit stream reader buffer. */
- this.bitsbuf = 0;
- /** @type {!number} bit stream reader buffer size. */
- this.bitsbuflen = 0;
- /** @type {!(Array.<number>|Uint8Array)} input buffer. */
- this.input = USE_TYPEDARRAY ? new Uint8Array(input) : input;
- /** @type {!(Uint8Array|Array.<number>)} output buffer. */
- this.output;
- /** @type {!number} output buffer pointer. */
- this.op;
- /** @type {boolean} is final block flag. */
- this.bfinal = false;
- /** @type {Zlib.RawInflate.BufferType} buffer management. */
- this.bufferType = Zlib.RawInflate.BufferType.ADAPTIVE;
- /** @type {boolean} resize flag for memory size optimization. */
- this.resize = false;
-
- // option parameters
- if (opt_params || !(opt_params = {})) {
- if (opt_params['index']) {
- this.ip = opt_params['index'];
- }
- if (opt_params['bufferSize']) {
- this.bufferSize = opt_params['bufferSize'];
- }
- if (opt_params['bufferType']) {
- this.bufferType = opt_params['bufferType'];
- }
- if (opt_params['resize']) {
- this.resize = opt_params['resize'];
- }
- }
-
- // initialize
- switch (this.bufferType) {
- case Zlib.RawInflate.BufferType.BLOCK:
- this.op = Zlib.RawInflate.MaxBackwardLength;
- this.output =
- new (USE_TYPEDARRAY ? Uint8Array : Array)(
- Zlib.RawInflate.MaxBackwardLength +
- this.bufferSize +
- Zlib.RawInflate.MaxCopyLength
- );
- break;
- case Zlib.RawInflate.BufferType.ADAPTIVE:
- this.op = 0;
- this.output = new (USE_TYPEDARRAY ? Uint8Array : Array)(this.bufferSize);
- this.expandBuffer = this.expandBufferAdaptive;
- this.concatBuffer = this.concatBufferDynamic;
- this.decodeHuffman = this.decodeHuffmanAdaptive;
- break;
- default:
- throw new Error('invalid inflate mode');
- }
-};
-
-/**
- * @enum {number}
- */
-Zlib.RawInflate.BufferType = {
- BLOCK: 0,
- ADAPTIVE: 1
-};
-
-/**
- * decompress.
- * @return {!(Uint8Array|Array.<number>)} inflated buffer.
- */
-Zlib.RawInflate.prototype.decompress = function() {
- while (!this.bfinal) {
- this.parseBlock();
- }
-
- return this.concatBuffer();
-};
-
-/**
- * @const
- * @type {number} max backward length for LZ77.
- */
-Zlib.RawInflate.MaxBackwardLength = 32768;
-
-/**
- * @const
- * @type {number} max copy length for LZ77.
- */
-Zlib.RawInflate.MaxCopyLength = 258;
-
-/**
- * huffman order
- * @const
- * @type {!(Array.<number>|Uint8Array)}
- */
-Zlib.RawInflate.Order = (function(table) {
- return USE_TYPEDARRAY ? new Uint16Array(table) : table;
-})([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
-
-/**
- * huffman length code table.
- * @const
- * @type {!(Array.<number>|Uint16Array)}
- */
-Zlib.RawInflate.LengthCodeTable = (function(table) {
- return USE_TYPEDARRAY ? new Uint16Array(table) : table;
-})([
- 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b,
- 0x000d, 0x000f, 0x0011, 0x0013, 0x0017, 0x001b, 0x001f, 0x0023, 0x002b,
- 0x0033, 0x003b, 0x0043, 0x0053, 0x0063, 0x0073, 0x0083, 0x00a3, 0x00c3,
- 0x00e3, 0x0102, 0x0102, 0x0102
-]);
-
-/**
- * huffman length extra-bits table.
- * @const
- * @type {!(Array.<number>|Uint8Array)}
- */
-Zlib.RawInflate.LengthExtraTable = (function(table) {
- return USE_TYPEDARRAY ? new Uint8Array(table) : table;
-})([
- 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5,
- 5, 5, 0, 0, 0
-]);
-
-/**
- * huffman dist code table.
- * @const
- * @type {!(Array.<number>|Uint16Array)}
- */
-Zlib.RawInflate.DistCodeTable = (function(table) {
- return USE_TYPEDARRAY ? new Uint16Array(table) : table;
-})([
- 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0007, 0x0009, 0x000d, 0x0011,
- 0x0019, 0x0021, 0x0031, 0x0041, 0x0061, 0x0081, 0x00c1, 0x0101, 0x0181,
- 0x0201, 0x0301, 0x0401, 0x0601, 0x0801, 0x0c01, 0x1001, 0x1801, 0x2001,
- 0x3001, 0x4001, 0x6001
-]);
-
-/**
- * huffman dist extra-bits table.
- * @const
- * @type {!(Array.<number>|Uint8Array)}
- */
-Zlib.RawInflate.DistExtraTable = (function(table) {
- return USE_TYPEDARRAY ? new Uint8Array(table) : table;
-})([
- 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11,
- 11, 12, 12, 13, 13
-]);
-
-/**
- * fixed huffman length code table
- * @const
- * @type {!Array}
- */
-Zlib.RawInflate.FixedLiteralLengthTable = (function(table) {
- return table;
-})((function() {
- var lengths = new (USE_TYPEDARRAY ? Uint8Array : Array)(288);
- var i, il;
-
- for (i = 0, il = lengths.length; i < il; ++i) {
- lengths[i] =
- (i <= 143) ? 8 :
- (i <= 255) ? 9 :
- (i <= 279) ? 7 :
- 8;
- }
-
- return buildHuffmanTable(lengths);
-})());
-
-/**
- * fixed huffman distance code table
- * @const
- * @type {!Array}
- */
-Zlib.RawInflate.FixedDistanceTable = (function(table) {
- return table;
-})((function() {
- var lengths = new (USE_TYPEDARRAY ? Uint8Array : Array)(30);
- var i, il;
-
- for (i = 0, il = lengths.length; i < il; ++i) {
- lengths[i] = 5;
- }
-
- return buildHuffmanTable(lengths);
-})());
-
-/**
- * parse deflated block.
- */
-Zlib.RawInflate.prototype.parseBlock = function() {
- /** @type {number} header */
- var hdr = this.readBits(3);
-
- // BFINAL
- if (hdr & 0x1) {
- this.bfinal = true;
- }
-
- // BTYPE
- hdr >>>= 1;
- switch (hdr) {
- // uncompressed
- case 0:
- this.parseUncompressedBlock();
- break;
- // fixed huffman
- case 1:
- this.parseFixedHuffmanBlock();
- break;
- // dynamic huffman
- case 2:
- this.parseDynamicHuffmanBlock();
- break;
- // reserved or other
- default:
- throw new Error('unknown BTYPE: ' + hdr);
- }
-};
-
-/**
- * read inflate bits
- * @param {number} length bits length.
- * @return {number} read bits.
- */
-Zlib.RawInflate.prototype.readBits = function(length) {
- var bitsbuf = this.bitsbuf;
- var bitsbuflen = this.bitsbuflen;
- var input = this.input;
- var ip = this.ip;
-
- /** @type {number} input and output byte. */
- var octet;
-
- // not enough buffer
- while (bitsbuflen < length) {
- // input byte
- octet = input[ip++];
- if (octet === void 0) {
- throw new Error('input buffer is broken');
- }
-
- // concat octet
- bitsbuf |= octet << bitsbuflen;
- bitsbuflen += 8;
- }
-
- // output byte
- octet = bitsbuf & /* MASK */ ((1 << length) - 1);
- bitsbuf >>>= length;
- bitsbuflen -= length;
-
- this.bitsbuf = bitsbuf;
- this.bitsbuflen = bitsbuflen;
- this.ip = ip;
-
- return octet;
-};
-
-/**
- * read huffman code using table
- * @param {Array} table huffman code table.
- * @return {number} huffman code.
- */
-Zlib.RawInflate.prototype.readCodeByTable = function(table) {
- var bitsbuf = this.bitsbuf;
- var bitsbuflen = this.bitsbuflen;
- var input = this.input;
- var ip = this.ip;
-
- /** @type {!(Array.<number>|Uint8Array)} huffman code table */
- var codeTable = table[0];
- /** @type {number} */
- var maxCodeLength = table[1];
- /** @type {number} input byte */
- var octet;
- /** @type {number} code length & code (16bit, 16bit) */
- var codeWithLength;
- /** @type {number} code bits length */
- var codeLength;
-
- // not enough buffer
- while (bitsbuflen < maxCodeLength) {
- octet = input[ip++];
- if (octet === void 0) {
- break;
- }
- bitsbuf |= octet << bitsbuflen;
- bitsbuflen += 8;
- }
-
- // read max length
- codeWithLength = codeTable[bitsbuf & ((1 << maxCodeLength) - 1)];
- codeLength = codeWithLength >>> 16;
-
- this.bitsbuf = bitsbuf >> codeLength;
- this.bitsbuflen = bitsbuflen - codeLength;
- this.ip = ip;
-
- return codeWithLength & 0xffff;
-};
-
-/**
- * parse uncompressed block.
- */
-Zlib.RawInflate.prototype.parseUncompressedBlock = function() {
- var input = this.input;
- var ip = this.ip;
- var output = this.output;
- var op = this.op;
-
- /** @type {number} input byte. */
- var octet;
- /** @type {number} block length */
- var len;
- /** @type {number} number for check block length */
- var nlen;
- /** @type {number} output buffer length */
- var olength = output.length;
- /** @type {number} copy counter */
- var preCopy;
-
- // skip buffered header bits
- this.bitsbuf = 0;
- this.bitsbuflen = 0;
-
- // len (1st)
- octet = input[ip++];
- if (octet === void 0) {
- throw new Error('invalid uncompressed block header: LEN (first byte)');
- }
- len = octet;
-
- // len (2nd)
- octet = input[ip++];
- if (octet === void 0) {
- throw new Error('invalid uncompressed block header: LEN (second byte)');
- }
- len |= octet << 8;
-
- // nlen (1st)
- octet = input[ip++];
- if (octet === void 0) {
- throw new Error('invalid uncompressed block header: NLEN (first byte)');
- }
- nlen = octet;
-
- // nlen (2nd)
- octet = input[ip++];
- if (octet === void 0) {
- throw new Error('invalid uncompressed block header: NLEN (second byte)');
- }
- nlen |= octet << 8;
-
- // check len & nlen
- if (len === ~nlen) {
- throw new Error('invalid uncompressed block header: length verify');
- }
-
- // check size
- if (ip + len > input.length) { throw new Error('input buffer is broken'); }
-
- // expand buffer
- switch (this.bufferType) {
- case Zlib.RawInflate.BufferType.BLOCK:
- // pre copy
- while (op + len > output.length) {
- preCopy = olength - op;
- len -= preCopy;
- if (USE_TYPEDARRAY) {
- output.set(input.subarray(ip, ip + preCopy), op);
- op += preCopy;
- ip += preCopy;
- } else {
- while (preCopy--) {
- output[op++] = input[ip++];
- }
- }
- this.op = op;
- output = this.expandBuffer();
- op = this.op;
- }
- break;
- case Zlib.RawInflate.BufferType.ADAPTIVE:
- while (op + len > output.length) {
- output = this.expandBuffer({fixRatio: 2});
- }
- break;
- default:
- throw new Error('invalid inflate mode');
- }
-
- // copy
- if (USE_TYPEDARRAY) {
- output.set(input.subarray(ip, ip + len), op);
- op += len;
- ip += len;
- } else {
- while (len--) {
- output[op++] = input[ip++];
- }
- }
-
- this.ip = ip;
- this.op = op;
- this.output = output;
-};
-
-/**
- * parse fixed huffman block.
- */
-Zlib.RawInflate.prototype.parseFixedHuffmanBlock = function() {
- this.decodeHuffman(
- Zlib.RawInflate.FixedLiteralLengthTable,
- Zlib.RawInflate.FixedDistanceTable
- );
-};
-
-/**
- * parse dynamic huffman block.
- */
-Zlib.RawInflate.prototype.parseDynamicHuffmanBlock = function() {
- /** @type {number} number of literal and length codes. */
- var hlit = this.readBits(5) + 257;
- /** @type {number} number of distance codes. */
- var hdist = this.readBits(5) + 1;
- /** @type {number} number of code lengths. */
- var hclen = this.readBits(4) + 4;
- /** @type {!(Uint8Array|Array.<number>)} code lengths. */
- var codeLengths =
- new (USE_TYPEDARRAY ? Uint8Array : Array)(Zlib.RawInflate.Order.length);
- /** @type {!Array} code lengths table. */
- var codeLengthsTable;
- /** @type {!(Uint8Array|Array.<number>)} literal and length code lengths. */
- var litlenLengths;
- /** @type {!(Uint8Array|Array.<number>)} distance code lengths. */
- var distLengths;
- /** @type {number} loop counter. */
- var i;
-
- // decode code lengths
- for (i = 0; i < hclen; ++i) {
- codeLengths[Zlib.RawInflate.Order[i]] = this.readBits(3);
- }
- codeLengthsTable = buildHuffmanTable(codeLengths);
-
- /**
- * decode function
- * @param {number} num number of lengths.
- * @param {!Array} table code lengths table.
- * @param {!(Uint8Array|Array.<number>)} lengths code lengths buffer.
- * @return {!(Uint8Array|Array.<number>)} code lengths buffer.
- */
- function decode(num, table, lengths) {
- /** @type {number} */
- var code;
- /** @type {number} */
- var prev;
- /** @type {number} */
- var repeat;
- /** @type {number} */
- var i;
-
- for (i = 0; i < num;) {
- code = this.readCodeByTable(table);
- switch (code) {
- case 16:
- repeat = 3 + this.readBits(2);
- while (repeat--) { lengths[i++] = prev; }
- break;
- case 17:
- repeat = 3 + this.readBits(3);
- while (repeat--) { lengths[i++] = 0; }
- prev = 0;
- break;
- case 18:
- repeat = 11 + this.readBits(7);
- while (repeat--) { lengths[i++] = 0; }
- prev = 0;
- break;
- default:
- lengths[i++] = code;
- prev = code;
- break;
- }
- }
-
- return lengths;
- }
-
- // literal and length code
- litlenLengths = new (USE_TYPEDARRAY ? Uint8Array : Array)(hlit);
-
- // distance code
- distLengths = new (USE_TYPEDARRAY ? Uint8Array : Array)(hdist);
-
- //return;
- this.decodeHuffman(
- buildHuffmanTable(decode.call(this, hlit, codeLengthsTable, litlenLengths)),
- buildHuffmanTable(decode.call(this, hdist, codeLengthsTable, distLengths))
- );
-};
-
-/**
- * decode huffman code
- * @param {!Array} litlen literal and length code table.
- * @param {!Array} dist distination code table.
- */
-Zlib.RawInflate.prototype.decodeHuffman = function(litlen, dist) {
- var output = this.output;
- var op = this.op;
-
- this.currentLitlenTable = litlen;
-
- /** @type {number} output position limit. */
- var olength = output.length - Zlib.RawInflate.MaxCopyLength;
- /** @type {number} huffman code. */
- var code;
- /** @type {number} table index. */
- var ti;
- /** @type {number} huffman code distination. */
- var codeDist;
- /** @type {number} huffman code length. */
- var codeLength;
-
- while ((code = this.readCodeByTable(litlen)) !== 256) {
- // literal
- if (code < 256) {
- if (op >= olength) {
- this.op = op;
- output = this.expandBuffer();
- op = this.op;
- }
- output[op++] = code;
-
- continue;
- }
-
- // length code
- ti = code - 257;
- codeLength = Zlib.RawInflate.LengthCodeTable[ti];
- if (Zlib.RawInflate.LengthExtraTable[ti] > 0) {
- codeLength += this.readBits(Zlib.RawInflate.LengthExtraTable[ti]);
- }
-
- // dist code
- code = this.readCodeByTable(dist);
- codeDist = Zlib.RawInflate.DistCodeTable[code];
- if (Zlib.RawInflate.DistExtraTable[code] > 0) {
- codeDist += this.readBits(Zlib.RawInflate.DistExtraTable[code]);
- }
-
- // lz77 decode
- if (op >= olength) {
- this.op = op;
- output = this.expandBuffer();
- op = this.op;
- }
- while (codeLength--) {
- output[op] = output[(op++) - codeDist];
- }
- }
-
- while (this.bitsbuflen >= 8) {
- this.bitsbuflen -= 8;
- this.ip--;
- }
- this.op = op;
-};
-
-/**
- * decode huffman code (adaptive)
- * @param {!Array} litlen literal and length code table.
- * @param {!Array} dist distination code table.
- */
-Zlib.RawInflate.prototype.decodeHuffmanAdaptive = function(litlen, dist) {
- var output = this.output;
- var op = this.op;
-
- this.currentLitlenTable = litlen;
-
- /** @type {number} output position limit. */
- var olength = output.length;
- /** @type {number} huffman code. */
- var code;
- /** @type {number} table index. */
- var ti;
- /** @type {number} huffman code distination. */
- var codeDist;
- /** @type {number} huffman code length. */
- var codeLength;
-
- while ((code = this.readCodeByTable(litlen)) !== 256) {
- // literal
- if (code < 256) {
- if (op >= olength) {
- output = this.expandBuffer();
- olength = output.length;
- }
- output[op++] = code;
-
- continue;
- }
-
- // length code
- ti = code - 257;
- codeLength = Zlib.RawInflate.LengthCodeTable[ti];
- if (Zlib.RawInflate.LengthExtraTable[ti] > 0) {
- codeLength += this.readBits(Zlib.RawInflate.LengthExtraTable[ti]);
- }
-
- // dist code
- code = this.readCodeByTable(dist);
- codeDist = Zlib.RawInflate.DistCodeTable[code];
- if (Zlib.RawInflate.DistExtraTable[code] > 0) {
- codeDist += this.readBits(Zlib.RawInflate.DistExtraTable[code]);
- }
-
- // lz77 decode
- if (op + codeLength > olength) {
- output = this.expandBuffer();
- olength = output.length;
- }
- while (codeLength--) {
- output[op] = output[(op++) - codeDist];
- }
- }
-
- while (this.bitsbuflen >= 8) {
- this.bitsbuflen -= 8;
- this.ip--;
- }
- this.op = op;
-};
-
-/**
- * expand output buffer.
- * @param {Object=} opt_param option parameters.
- * @return {!(Array.<number>|Uint8Array)} output buffer.
- */
-Zlib.RawInflate.prototype.expandBuffer = function(opt_param) {
- /** @type {!(Array.<number>|Uint8Array)} store buffer. */
- var buffer =
- new (USE_TYPEDARRAY ? Uint8Array : Array)(
- this.op - Zlib.RawInflate.MaxBackwardLength
- );
- /** @type {number} backward base point */
- var backward = this.op - Zlib.RawInflate.MaxBackwardLength;
- /** @type {number} copy index. */
- var i;
- /** @type {number} copy limit */
- var il;
-
- var output = this.output;
-
- // copy to output buffer
- if (USE_TYPEDARRAY) {
- buffer.set(output.subarray(Zlib.RawInflate.MaxBackwardLength, buffer.length));
- } else {
- for (i = 0, il = buffer.length; i < il; ++i) {
- buffer[i] = output[i + Zlib.RawInflate.MaxBackwardLength];
- }
- }
-
- this.blocks.push(buffer);
- this.totalpos += buffer.length;
-
- // copy to backward buffer
- if (USE_TYPEDARRAY) {
- output.set(
- output.subarray(backward, backward + Zlib.RawInflate.MaxBackwardLength)
- );
- } else {
- for (i = 0; i < Zlib.RawInflate.MaxBackwardLength; ++i) {
- output[i] = output[backward + i];
- }
- }
-
- this.op = Zlib.RawInflate.MaxBackwardLength;
-
- return output;
-};
-
-/**
- * expand output buffer. (adaptive)
- * @param {Object=} opt_param option parameters.
- * @return {!(Array.<number>|Uint8Array)} output buffer pointer.
- */
-Zlib.RawInflate.prototype.expandBufferAdaptive = function(opt_param) {
- /** @type {!(Array.<number>|Uint8Array)} store buffer. */
- var buffer;
- /** @type {number} expantion ratio. */
- var ratio = (this.input.length / this.ip + 1) | 0;
- /** @type {number} maximum number of huffman code. */
- var maxHuffCode;
- /** @type {number} new output buffer size. */
- var newSize;
- /** @type {number} max inflate size. */
- var maxInflateSize;
-
- var input = this.input;
- var output = this.output;
-
- if (opt_param) {
- if (typeof opt_param.fixRatio === 'number') {
- ratio = opt_param.fixRatio;
- }
- if (typeof opt_param.addRatio === 'number') {
- ratio += opt_param.addRatio;
- }
- }
-
- // calculate new buffer size
- if (ratio < 2) {
- maxHuffCode =
- (input.length - this.ip) / this.currentLitlenTable[2];
- maxInflateSize = (maxHuffCode / 2 * 258) | 0;
- newSize = maxInflateSize < output.length ?
- output.length + maxInflateSize :
- output.length << 1;
- } else {
- newSize = output.length * ratio;
- }
-
- // buffer expantion
- if (USE_TYPEDARRAY) {
- buffer = new Uint8Array(newSize);
- buffer.set(output);
- } else {
- buffer = output;
- }
-
- this.output = buffer;
-
- return this.output;
-};
-
-/**
- * concat output buffer.
- * @return {!(Array.<number>|Uint8Array)} output buffer.
- */
-Zlib.RawInflate.prototype.concatBuffer = function() {
- /** @type {number} buffer pointer. */
- var pos = 0;
- /** @type {number} buffer pointer. */
- var limit = this.totalpos + (this.op - Zlib.RawInflate.MaxBackwardLength);
- /** @type {!(Array.<number>|Uint8Array)} output block array. */
- var output = this.output;
- /** @type {!Array} blocks array. */
- var blocks = this.blocks;
- /** @type {!(Array.<number>|Uint8Array)} output block array. */
- var block;
- /** @type {!(Array.<number>|Uint8Array)} output buffer. */
- var buffer = new (USE_TYPEDARRAY ? Uint8Array : Array)(limit);
- /** @type {number} loop counter. */
- var i;
- /** @type {number} loop limiter. */
- var il;
- /** @type {number} loop counter. */
- var j;
- /** @type {number} loop limiter. */
- var jl;
-
- // single buffer
- if (blocks.length === 0) {
- return USE_TYPEDARRAY ?
- this.output.subarray(Zlib.RawInflate.MaxBackwardLength, this.op) :
- this.output.slice(Zlib.RawInflate.MaxBackwardLength, this.op);
- }
-
- // copy to buffer
- for (i = 0, il = blocks.length; i < il; ++i) {
- block = blocks[i];
- for (j = 0, jl = block.length; j < jl; ++j) {
- buffer[pos++] = block[j];
- }
- }
-
- // current buffer
- for (i = Zlib.RawInflate.MaxBackwardLength, il = this.op; i < il; ++i) {
- buffer[pos++] = output[i];
- }
-
- this.blocks = [];
- this.buffer = buffer;
-
- return this.buffer;
-};
-
-/**
- * concat output buffer. (dynamic)
- * @return {!(Array.<number>|Uint8Array)} output buffer.
- */
-Zlib.RawInflate.prototype.concatBufferDynamic = function() {
- /** @type {Array.<number>|Uint8Array} output buffer. */
- var buffer;
- var op = this.op;
-
- if (USE_TYPEDARRAY) {
- if (this.resize) {
- buffer = new Uint8Array(op);
- buffer.set(this.output.subarray(0, op));
- } else {
- buffer = this.output.subarray(0, op);
- }
- } else {
- if (this.output.length > op) {
- this.output.length = op;
- }
- buffer = this.output;
- }
-
- this.buffer = buffer;
-
- return this.buffer;
-};
-
-// end of scope
-});
-
-/* vim:set expandtab ts=2 sw=2 tw=80: */
+++ /dev/null
-goog.provide('Zlib.RawInflateStream');
-
-goog.require('USE_TYPEDARRAY');
-goog.require('Zlib.Huffman');
-
-//-----------------------------------------------------------------------------
-
-/** @define {number} buffer block size. */
-var ZLIB_STREAM_RAW_INFLATE_BUFFER_SIZE = 0x8000;
-
-//-----------------------------------------------------------------------------
-
-goog.scope(function() {
-
-var buildHuffmanTable = Zlib.Huffman.buildHuffmanTable;
-
-/**
- * @param {!(Uint8Array|Array.<number>)} input input buffer.
- * @param {number} ip input buffer pointer.
- * @param {number=} opt_buffersize buffer block size.
- * @constructor
- */
-Zlib.RawInflateStream = function(input, ip, opt_buffersize) {
- /** @type {!(Array|Uint8Array)} inflated buffer */
- this.buffer;
- /** @type {!Array.<(Array|Uint8Array)>} */
- this.blocks = [];
- /** @type {number} block size. */
- this.bufferSize =
- opt_buffersize ? opt_buffersize : ZLIB_STREAM_RAW_INFLATE_BUFFER_SIZE;
- /** @type {!number} total output buffer pointer. */
- this.totalpos = 0;
- /** @type {!number} input buffer pointer. */
- this.ip = ip === void 0 ? 0 : ip;
- /** @type {!number} bit stream reader buffer. */
- this.bitsbuf = 0;
- /** @type {!number} bit stream reader buffer size. */
- this.bitsbuflen = 0;
- /** @type {!(Array|Uint8Array)} input buffer. */
- this.input = USE_TYPEDARRAY ? new Uint8Array(input) : input;
- /** @type {!(Uint8Array|Array)} output buffer. */
- this.output = new (USE_TYPEDARRAY ? Uint8Array : Array)(this.bufferSize);
- /** @type {!number} output buffer pointer. */
- this.op = 0;
- /** @type {boolean} is final block flag. */
- this.bfinal = false;
- /** @type {number} uncompressed block length. */
- this.blockLength;
- /** @type {boolean} resize flag for memory size optimization. */
- this.resize = false;
- /** @type {Array} */
- this.litlenTable;
- /** @type {Array} */
- this.distTable;
- /** @type {number} */
- this.sp = 0; // stream pointer
- /** @type {Zlib.RawInflateStream.Status} */
- this.status = Zlib.RawInflateStream.Status.INITIALIZED;
-
- //
- // backup
- //
- /** @type {!number} */
- this.ip_;
- /** @type {!number} */
- this.bitsbuflen_;
- /** @type {!number} */
- this.bitsbuf_;
-};
-
-/**
- * @enum {number}
- */
-Zlib.RawInflateStream.BlockType = {
- UNCOMPRESSED: 0,
- FIXED: 1,
- DYNAMIC: 2
-};
-
-/**
- * @enum {number}
- */
-Zlib.RawInflateStream.Status = {
- INITIALIZED: 0,
- BLOCK_HEADER_START: 1,
- BLOCK_HEADER_END: 2,
- BLOCK_BODY_START: 3,
- BLOCK_BODY_END: 4,
- DECODE_BLOCK_START: 5,
- DECODE_BLOCK_END: 6
-};
-
-/**
- * decompress.
- * @return {!(Uint8Array|Array)} inflated buffer.
- */
-Zlib.RawInflateStream.prototype.decompress = function(newInput, ip) {
- /** @type {boolean} */
- var stop = false;
-
- if (newInput !== void 0) {
- this.input = newInput;
- }
-
- if (ip !== void 0) {
- this.ip = ip;
- }
-
- // decompress
- while (!stop) {
- switch (this.status) {
- // block header
- case Zlib.RawInflateStream.Status.INITIALIZED:
- case Zlib.RawInflateStream.Status.BLOCK_HEADER_START:
- if (this.readBlockHeader() < 0) {
- stop = true;
- }
- break;
- // block body
- case Zlib.RawInflateStream.Status.BLOCK_HEADER_END: /* FALLTHROUGH */
- case Zlib.RawInflateStream.Status.BLOCK_BODY_START:
- switch(this.currentBlockType) {
- case Zlib.RawInflateStream.BlockType.UNCOMPRESSED:
- if (this.readUncompressedBlockHeader() < 0) {
- stop = true;
- }
- break;
- case Zlib.RawInflateStream.BlockType.FIXED:
- if (this.parseFixedHuffmanBlock() < 0) {
- stop = true;
- }
- break;
- case Zlib.RawInflateStream.BlockType.DYNAMIC:
- if (this.parseDynamicHuffmanBlock() < 0) {
- stop = true;
- }
- break;
- }
- break;
- // decode data
- case Zlib.RawInflateStream.Status.BLOCK_BODY_END:
- case Zlib.RawInflateStream.Status.DECODE_BLOCK_START:
- switch(this.currentBlockType) {
- case Zlib.RawInflateStream.BlockType.UNCOMPRESSED:
- if (this.parseUncompressedBlock() < 0) {
- stop = true;
- }
- break;
- case Zlib.RawInflateStream.BlockType.FIXED: /* FALLTHROUGH */
- case Zlib.RawInflateStream.BlockType.DYNAMIC:
- if (this.decodeHuffman() < 0) {
- stop = true;
- }
- break;
- }
- break;
- case Zlib.RawInflateStream.Status.DECODE_BLOCK_END:
- if (this.bfinal) {
- stop = true;
- } else {
- this.status = Zlib.RawInflateStream.Status.INITIALIZED;
- }
- break;
- }
- }
-
- return this.concatBuffer();
-};
-
-/**
- * @const
- * @type {number} max backward length for LZ77.
- */
-Zlib.RawInflateStream.MaxBackwardLength = 32768;
-
-/**
- * @const
- * @type {number} max copy length for LZ77.
- */
-Zlib.RawInflateStream.MaxCopyLength = 258;
-
-/**
- * huffman order
- * @const
- * @type {!(Array.<number>|Uint8Array)}
- */
-Zlib.RawInflateStream.Order = (function(table) {
- return USE_TYPEDARRAY ? new Uint16Array(table) : table;
-})([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
-
-/**
- * huffman length code table.
- * @const
- * @type {!(Array.<number>|Uint16Array)}
- */
-Zlib.RawInflateStream.LengthCodeTable = (function(table) {
- return USE_TYPEDARRAY ? new Uint16Array(table) : table;
-})([
- 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b,
- 0x000d, 0x000f, 0x0011, 0x0013, 0x0017, 0x001b, 0x001f, 0x0023, 0x002b,
- 0x0033, 0x003b, 0x0043, 0x0053, 0x0063, 0x0073, 0x0083, 0x00a3, 0x00c3,
- 0x00e3, 0x0102, 0x0102, 0x0102
-]);
-
-/**
- * huffman length extra-bits table.
- * @const
- * @type {!(Array.<number>|Uint8Array)}
- */
-Zlib.RawInflateStream.LengthExtraTable = (function(table) {
- return USE_TYPEDARRAY ? new Uint8Array(table) : table;
-})([
- 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5,
- 5, 5, 0, 0, 0
-]);
-
-/**
- * huffman dist code table.
- * @const
- * @type {!(Array.<number>|Uint16Array)}
- */
-Zlib.RawInflateStream.DistCodeTable = (function(table) {
- return USE_TYPEDARRAY ? new Uint16Array(table) : table;
-})([
- 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0007, 0x0009, 0x000d, 0x0011,
- 0x0019, 0x0021, 0x0031, 0x0041, 0x0061, 0x0081, 0x00c1, 0x0101, 0x0181,
- 0x0201, 0x0301, 0x0401, 0x0601, 0x0801, 0x0c01, 0x1001, 0x1801, 0x2001,
- 0x3001, 0x4001, 0x6001
-]);
-
-/**
- * huffman dist extra-bits table.
- * @const
- * @type {!(Array.<number>|Uint8Array)}
- */
-Zlib.RawInflateStream.DistExtraTable = (function(table) {
- return USE_TYPEDARRAY ? new Uint8Array(table) : table;
-})([
- 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11,
- 11, 12, 12, 13, 13
-]);
-
-/**
- * fixed huffman length code table
- * @const
- * @type {!Array}
- */
-Zlib.RawInflateStream.FixedLiteralLengthTable = (function(table) {
- return table;
-})((function() {
- var lengths = new (USE_TYPEDARRAY ? Uint8Array : Array)(288);
- var i, il;
-
- for (i = 0, il = lengths.length; i < il; ++i) {
- lengths[i] =
- (i <= 143) ? 8 :
- (i <= 255) ? 9 :
- (i <= 279) ? 7 :
- 8;
- }
-
- return buildHuffmanTable(lengths);
-})());
-
-/**
- * fixed huffman distance code table
- * @const
- * @type {!Array}
- */
-Zlib.RawInflateStream.FixedDistanceTable = (function(table) {
- return table;
-})((function() {
- var lengths = new (USE_TYPEDARRAY ? Uint8Array : Array)(30);
- var i, il;
-
- for (i = 0, il = lengths.length; i < il; ++i) {
- lengths[i] = 5;
- }
-
- return buildHuffmanTable(lengths);
-})());
-
-/**
- * parse deflated block.
- */
-Zlib.RawInflateStream.prototype.readBlockHeader = function() {
- /** @type {number} header */
- var hdr;
-
- this.status = Zlib.RawInflateStream.Status.BLOCK_HEADER_START;
-
- this.save_();
- if ((hdr = this.readBits(3)) < 0) {
- this.restore_();
- return -1;
- }
-
- // BFINAL
- if (hdr & 0x1) {
- this.bfinal = true;
- }
-
- // BTYPE
- hdr >>>= 1;
- switch (hdr) {
- case 0: // uncompressed
- this.currentBlockType = Zlib.RawInflateStream.BlockType.UNCOMPRESSED;
- break;
- case 1: // fixed huffman
- this.currentBlockType = Zlib.RawInflateStream.BlockType.FIXED;
- break;
- case 2: // dynamic huffman
- this.currentBlockType = Zlib.RawInflateStream.BlockType.DYNAMIC;
- break;
- default: // reserved or other
- throw new Error('unknown BTYPE: ' + hdr);
- }
-
- this.status = Zlib.RawInflateStream.Status.BLOCK_HEADER_END;
-};
-
-/**
- * read inflate bits
- * @param {number} length bits length.
- * @return {number} read bits.
- */
-Zlib.RawInflateStream.prototype.readBits = function(length) {
- var bitsbuf = this.bitsbuf;
- var bitsbuflen = this.bitsbuflen;
- var input = this.input;
- var ip = this.ip;
-
- /** @type {number} input and output byte. */
- var octet;
-
- // not enough buffer
- while (bitsbuflen < length) {
- // input byte
- octet = input[ip++];
- if (octet === void 0) {
- return -1;
- }
-
- // concat octet
- bitsbuf |= octet << bitsbuflen;
- bitsbuflen += 8;
- }
-
- // output byte
- octet = bitsbuf & /* MASK */ ((1 << length) - 1);
- bitsbuf >>>= length;
- bitsbuflen -= length;
-
- this.bitsbuf = bitsbuf;
- this.bitsbuflen = bitsbuflen;
- this.ip = ip;
-
- return octet;
-};
-
-/**
- * read huffman code using table
- * @param {Array} table huffman code table.
- * @return {number} huffman code.
- */
-Zlib.RawInflateStream.prototype.readCodeByTable = function(table) {
- var bitsbuf = this.bitsbuf;
- var bitsbuflen = this.bitsbuflen;
- var input = this.input;
- var ip = this.ip;
-
- /** @type {!(Array|Uint8Array)} huffman code table */
- var codeTable = table[0];
- /** @type {number} */
- var maxCodeLength = table[1];
- /** @type {number} input byte */
- var octet;
- /** @type {number} code */
- var code;
- /** @type {number} code length & code (16bit, 16bit) */
- var codeWithLength;
- /** @type {number} code bits length */
- var codeLength;
-
- // not enough buffer
- while (bitsbuflen < maxCodeLength) {
- octet = input[ip++];
- if (octet === void 0) {
- return -1;
- }
- bitsbuf |= octet << bitsbuflen;
- bitsbuflen += 8;
- }
-
- // read max length
- codeWithLength = codeTable[bitsbuf & ((1 << maxCodeLength) - 1)];
- codeLength = codeWithLength >>> 16;
-
- this.bitsbuf = bitsbuf >> codeLength;
- this.bitsbuflen = bitsbuflen - codeLength;
- this.ip = ip;
-
- return codeWithLength & 0xffff;
-};
-
-/**
- * read uncompressed block header
- */
-Zlib.RawInflateStream.prototype.readUncompressedBlockHeader = function() {
- /** @type {number} input byte. */
- var octet;
- /** @type {number} block length */
- var len;
- /** @type {number} number for check block length */
- var nlen;
-
- var input = this.input;
- var ip = this.ip;
-
- this.status = Zlib.RawInflateStream.Status.BLOCK_BODY_START;
-
- // len (1st)
- octet = input[ip++];
- if (octet === void 0) {
- return -1;
- }
- len = octet;
-
- // len (2nd)
- octet = input[ip++];
- if (octet === void 0) {
- return -1;
- }
- len |= octet << 8;
-
- // nlen (1st)
- octet = input[ip++];
- if (octet === void 0) {
- return -1;
- }
- nlen = octet;
-
- // nlen (2nd)
- octet = input[ip++];
- if (octet === void 0) {
- return -1;
- }
- nlen |= octet << 8;
-
- // check len & nlen
- if (len === ~nlen) {
- throw new Error('invalid uncompressed block header: length verify');
- }
-
- // skip buffered header bits
- this.bitsbuf = 0;
- this.bitsbuflen = 0;
-
- this.ip = ip;
- this.blockLength = len;
- this.status = Zlib.RawInflateStream.Status.BLOCK_BODY_END;
-}
-
-/**
- * parse uncompressed block.
- */
-Zlib.RawInflateStream.prototype.parseUncompressedBlock = function() {
- var input = this.input;
- var ip = this.ip;
- var output = this.output;
- var op = this.op;
- var len = this.blockLength;
-
- this.status = Zlib.RawInflateStream.Status.DECODE_BLOCK_START;
-
- // copy
- // XXX: とりあえず素直にコピー
- while (len--) {
- if (op === output.length) {
- output = this.expandBuffer();
- }
-
- // not enough input buffer
- if (input[ip] === void 0) {
- this.ip = ip;
- this.op = op;
- this.blockLength = len + 1; // コピーしてないので戻す
- return -1;
- }
-
- output[op++] = input[ip++];
- }
-
- if (len < 0) {
- this.status = Zlib.RawInflateStream.Status.DECODE_BLOCK_END;
- }
-
- this.ip = ip;
- this.op = op;
-
- return 0;
-};
-
-/**
- * parse fixed huffman block.
- */
-Zlib.RawInflateStream.prototype.parseFixedHuffmanBlock = function() {
- this.status = Zlib.RawInflateStream.Status.BLOCK_BODY_START;
-
- this.litlenTable = Zlib.RawInflateStream.FixedLiteralLengthTable;
- this.distTable = Zlib.RawInflateStream.FixedDistanceTable;
-
- this.status = Zlib.RawInflateStream.Status.BLOCK_BODY_END;
-
- return 0;
-};
-
-/**
- * オブジェクトのコンテキストを別のプロパティに退避する.
- * @private
- */
-Zlib.RawInflateStream.prototype.save_ = function() {
- this.ip_ = this.ip;
- this.bitsbuflen_ = this.bitsbuflen;
- this.bitsbuf_ = this.bitsbuf;
-};
-
-/**
- * 別のプロパティに退避したコンテキストを復元する.
- * @private
- */
-Zlib.RawInflateStream.prototype.restore_ = function() {
- this.ip = this.ip_;
- this.bitsbuflen = this.bitsbuflen_;
- this.bitsbuf = this.bitsbuf_;
-};
-
-/**
- * parse dynamic huffman block.
- */
-Zlib.RawInflateStream.prototype.parseDynamicHuffmanBlock = function() {
- /** @type {number} number of literal and length codes. */
- var hlit;
- /** @type {number} number of distance codes. */
- var hdist;
- /** @type {number} number of code lengths. */
- var hclen;
- /** @type {!(Uint8Array|Array)} code lengths. */
- var codeLengths =
- new (USE_TYPEDARRAY ? Uint8Array : Array)(Zlib.RawInflateStream.Order.length);
- /** @type {!Array} code lengths table. */
- var codeLengthsTable;
- /** @type {!(Uint32Array|Array)} literal and length code lengths. */
- var litlenLengths;
- /** @type {!(Uint32Array|Array)} distance code lengths. */
- var distLengths;
- /** @type {number} loop counter. */
- var i = 0;
- /** @type {number} loop counter. */
- var j = 0;
-
- this.status = Zlib.RawInflateStream.Status.BLOCK_BODY_START;
-
- this.save_();
- hlit = this.readBits(5) + 257;
- hdist = this.readBits(5) + 1;
- hclen = this.readBits(4) + 4;
- if (hlit < 0 || hdist < 0 || hclen < 0) {
- this.restore_();
- return -1;
- }
-
- try {
- parseDynamicHuffmanBlockImpl.call(this);
- } catch(e) {
- this.restore_();
- return -1;
- }
-
- function parseDynamicHuffmanBlockImpl() {
- /** @type {number} */
- var bits;
-
- // decode code lengths
- for (i = 0; i < hclen; ++i) {
- if ((bits = this.readBits(3)) < 0) {
- throw new Error('not enough input');
- }
- codeLengths[Zlib.RawInflateStream.Order[i]] = bits;
- }
- codeLengthsTable = buildHuffmanTable(codeLengths);
-
- // decode function
- function decode(num, table, lengths) {
- var code;
- var prev;
- var repeat;
- var i = 0;
- var bits;
-
- for (i = 0; i < num;) {
- code = this.readCodeByTable(table);
- if (code < 0) {
- throw new Error('not enough input');
- }
- switch (code) {
- case 16:
- if ((bits = this.readBits(2)) < 0) {
- throw new Error('not enough input');
- };
- repeat = 3 + bits;
- while (repeat--) { lengths[i++] = prev; }
- break;
- case 17:
- if ((bits = this.readBits(3)) < 0) {
- throw new Error('not enough input');
- };
- repeat = 3 + bits;
- while (repeat--) { lengths[i++] = 0; }
- prev = 0;
- break;
- case 18:
- if ((bits = this.readBits(7)) < 0) {
- throw new Error('not enough input');
- };
- repeat = 11 + bits;
- while (repeat--) { lengths[i++] = 0; }
- prev = 0;
- break;
- default:
- lengths[i++] = code;
- prev = code;
- break;
- }
- }
-
- return lengths;
- }
-
- // literal and length code
- litlenLengths = new (USE_TYPEDARRAY ? Uint8Array : Array)(hlit);
-
- // distance code
- distLengths = new (USE_TYPEDARRAY ? Uint8Array : Array)(hdist);
-
- this.litlenTable = buildHuffmanTable(decode.call(this, hlit, codeLengthsTable, litlenLengths));
- this.distTable = buildHuffmanTable(decode.call(this, hdist, codeLengthsTable, distLengths));
- }
-
- this.status = Zlib.RawInflateStream.Status.BLOCK_BODY_END;
-
- return 0;
-};
-
-/**
- * decode huffman code (dynamic)
- * @return {(number|undefined)} -1 is error.
- */
-Zlib.RawInflateStream.prototype.decodeHuffman = function() {
- var output = this.output;
- var op = this.op;
-
- /** @type {number} huffman code. */
- var code;
- /** @type {number} table index. */
- var ti;
- /** @type {number} huffman code distination. */
- var codeDist;
- /** @type {number} huffman code length. */
- var codeLength;
- /** @type {number} buffer position. */
- var bpos;
- /** @type {number} pre-copy counter. */
- var preCopy;
-
- var litlen = this.litlenTable;
- var dist = this.distTable;
-
- var olength = output.length;
- var bits;
-
- this.status = Zlib.RawInflateStream.Status.DECODE_BLOCK_START;
-
- while (true) {
- this.save_();
-
- code = this.readCodeByTable(litlen);
- if (code < 0) {
- this.op = op;
- this.restore_();
- return -1;
- }
-
- if (code === 256) {
- break;
- }
-
- // literal
- if (code < 256) {
- if (op === olength) {
- output = this.expandBuffer();
- olength = output.length;
- }
- output[op++] = code;
-
- continue;
- }
-
- // length code
- ti = code - 257;
- codeLength = Zlib.RawInflateStream.LengthCodeTable[ti];
- if (Zlib.RawInflateStream.LengthExtraTable[ti] > 0) {
- bits = this.readBits(Zlib.RawInflateStream.LengthExtraTable[ti]);
- if (bits < 0) {
- this.op = op;
- this.restore_();
- return -1;
- }
- codeLength += bits;
- }
-
- // dist code
- code = this.readCodeByTable(dist);
- if (code < 0) {
- this.op = op;
- this.restore_();
- return -1;
- }
- codeDist = Zlib.RawInflateStream.DistCodeTable[code];
- if (Zlib.RawInflateStream.DistExtraTable[code] > 0) {
- bits = this.readBits(Zlib.RawInflateStream.DistExtraTable[code]);
- if (bits < 0) {
- this.op = op;
- this.restore_();
- return -1;
- }
- codeDist += bits;
- }
-
- // lz77 decode
- if (op + codeLength >= olength) {
- output = this.expandBuffer();
- olength = output.length;
- }
-
- while (codeLength--) {
- output[op] = output[(op++) - codeDist];
- }
-
- // break
- if (this.ip === this.input.length) {
- this.op = op;
- return -1;
- }
- }
-
- while (this.bitsbuflen >= 8) {
- this.bitsbuflen -= 8;
- this.ip--;
- }
-
- this.op = op;
- this.status = Zlib.RawInflateStream.Status.DECODE_BLOCK_END;
-};
-
-/**
- * expand output buffer. (dynamic)
- * @param {Object=} opt_param option parameters.
- * @return {!(Array|Uint8Array)} output buffer pointer.
- */
-Zlib.RawInflateStream.prototype.expandBuffer = function(opt_param) {
- /** @type {!(Array|Uint8Array)} store buffer. */
- var buffer;
- /** @type {number} expantion ratio. */
- var ratio = (this.input.length / this.ip + 1) | 0;
- /** @type {number} maximum number of huffman code. */
- var maxHuffCode;
- /** @type {number} new output buffer size. */
- var newSize;
- /** @type {number} max inflate size. */
- var maxInflateSize;
-
- var input = this.input;
- var output = this.output;
-
- if (opt_param) {
- if (typeof opt_param.fixRatio === 'number') {
- ratio = opt_param.fixRatio;
- }
- if (typeof opt_param.addRatio === 'number') {
- ratio += opt_param.addRatio;
- }
- }
-
- // calculate new buffer size
- if (ratio < 2) {
- maxHuffCode =
- (input.length - this.ip) / this.litlenTable[2];
- maxInflateSize = (maxHuffCode / 2 * 258) | 0;
- newSize = maxInflateSize < output.length ?
- output.length + maxInflateSize :
- output.length << 1;
- } else {
- newSize = output.length * ratio;
- }
-
- // buffer expantion
- if (USE_TYPEDARRAY) {
- buffer = new Uint8Array(newSize);
- buffer.set(output);
- } else {
- buffer = output;
- }
-
- this.output = buffer;
-
- return this.output;
-};
-
-/**
- * concat output buffer. (dynamic)
- * @return {!(Array|Uint8Array)} output buffer.
- */
-Zlib.RawInflateStream.prototype.concatBuffer = function() {
- /** @type {!(Array|Uint8Array)} output buffer. */
- var buffer;
-
- var resize = this.resize;
-
- var op = this.op;
-
- if (resize) {
- if (USE_TYPEDARRAY) {
- buffer = new Uint8Array(op);
- buffer.set(this.output.subarray(this.sp, op));
- } else {
- buffer = this.output.slice(this.sp, op);
- }
- } else {
- buffer =
- USE_TYPEDARRAY ? this.output.subarray(this.sp, op) : this.output.slice(this.sp, op);
- }
-
-
- this.buffer = buffer;
- this.sp = op;
-
- return this.buffer;
-};
-
-/**
- * @return {!(Array|Uint8Array)} current output buffer.
- */
-Zlib.RawInflateStream.prototype.getBytes = function() {
- return USE_TYPEDARRAY ?
- this.output.subarray(0, this.op) : this.output.slice(0, this.op);
-};
-
-// end of scope
-});
-
-/* vim:set expandtab ts=2 sw=2 tw=80: */
+++ /dev/null
-goog.provide('Zlib.Unzip');
-
-goog.require('USE_TYPEDARRAY');
-goog.require('Zlib.RawInflate');
-goog.require('Zlib.CRC32');
-goog.require('Zlib.Zip');
-
-goog.scope(function() {
-
-/**
- * @param {!(Array.<number>|Uint8Array)} input input buffer.
- * @param {Object=} opt_params options.
- * @constructor
- */
-Zlib.Unzip = function(input, opt_params) {
- opt_params = opt_params || {};
- /** @type {!(Array.<number>|Uint8Array)} */
- this.input =
- (USE_TYPEDARRAY && (input instanceof Array)) ?
- new Uint8Array(input) : input;
- /** @type {number} */
- this.ip = 0;
- /** @type {number} */
- this.eocdrOffset;
- /** @type {number} */
- this.numberOfThisDisk;
- /** @type {number} */
- this.startDisk;
- /** @type {number} */
- this.totalEntriesThisDisk;
- /** @type {number} */
- this.totalEntries;
- /** @type {number} */
- this.centralDirectorySize;
- /** @type {number} */
- this.centralDirectoryOffset;
- /** @type {number} */
- this.commentLength;
- /** @type {(Array.<number>|Uint8Array)} */
- this.comment;
- /** @type {Array.<Zlib.Unzip.FileHeader>} */
- this.fileHeaderList;
- /** @type {Object.<string, number>} */
- this.filenameToIndex;
- /** @type {boolean} */
- this.verify = opt_params['verify'] || false;
- /** @type {(Array.<number>|Uint8Array)} */
- this.password = opt_params['password'];
-};
-
-Zlib.Unzip.CompressionMethod = Zlib.Zip.CompressionMethod;
-
-/**
- * @param {!(Array.<number>|Uint8Array)} input input buffer.
- * @param {number} ip input position.
- * @constructor
- */
-Zlib.Unzip.FileHeader = function(input, ip) {
- /** @type {!(Array.<number>|Uint8Array)} */
- this.input = input;
- /** @type {number} */
- this.offset = ip;
- /** @type {number} */
- this.length;
- /** @type {number} */
- this.version;
- /** @type {number} */
- this.os;
- /** @type {number} */
- this.needVersion;
- /** @type {number} */
- this.flags;
- /** @type {number} */
- this.compression;
- /** @type {number} */
- this.time;
- /** @type {number} */
- this.date;
- /** @type {number} */
- this.crc32;
- /** @type {number} */
- this.compressedSize;
- /** @type {number} */
- this.plainSize;
- /** @type {number} */
- this.fileNameLength;
- /** @type {number} */
- this.extraFieldLength;
- /** @type {number} */
- this.fileCommentLength;
- /** @type {number} */
- this.diskNumberStart;
- /** @type {number} */
- this.internalFileAttributes;
- /** @type {number} */
- this.externalFileAttributes;
- /** @type {number} */
- this.relativeOffset;
- /** @type {string} */
- this.filename;
- /** @type {!(Array.<number>|Uint8Array)} */
- this.extraField;
- /** @type {!(Array.<number>|Uint8Array)} */
- this.comment;
-};
-
-Zlib.Unzip.FileHeader.prototype.parse = function() {
- /** @type {!(Array.<number>|Uint8Array)} */
- var input = this.input;
- /** @type {number} */
- var ip = this.offset;
-
- // central file header signature
- if (input[ip++] !== 0x50 || input[ip++] !== 0x4b ||
- input[ip++] !== 0x01 || input[ip++] !== 0x02) {
- throw new Error('invalid file header signature');
- }
-
- // version made by
- this.version = input[ip++];
- this.os = input[ip++];
-
- // version needed to extract
- this.needVersion = input[ip++] | (input[ip++] << 8);
-
- // general purpose bit flag
- this.flags = input[ip++] | (input[ip++] << 8);
-
- // compression method
- this.compression = input[ip++] | (input[ip++] << 8);
-
- // last mod file time
- this.time = input[ip++] | (input[ip++] << 8);
-
- //last mod file date
- this.date = input[ip++] | (input[ip++] << 8);
-
- // crc-32
- this.crc32 = (
- (input[ip++] ) | (input[ip++] << 8) |
- (input[ip++] << 16) | (input[ip++] << 24)
- ) >>> 0;
-
- // compressed size
- this.compressedSize =
- (input[ip++] ) | (input[ip++] << 8) |
- (input[ip++] << 16) | (input[ip++] << 24);
-
- // uncompressed size
- this.plainSize =
- (input[ip++] ) | (input[ip++] << 8) |
- (input[ip++] << 16) | (input[ip++] << 24);
-
- // file name length
- this.fileNameLength = input[ip++] | (input[ip++] << 8);
-
- // extra field length
- this.extraFieldLength = input[ip++] | (input[ip++] << 8);
-
- // file comment length
- this.fileCommentLength = input[ip++] | (input[ip++] << 8);
-
- // disk number start
- this.diskNumberStart = input[ip++] | (input[ip++] << 8);
-
- // internal file attributes
- this.internalFileAttributes = input[ip++] | (input[ip++] << 8);
-
- // external file attributes
- this.externalFileAttributes =
- (input[ip++] ) | (input[ip++] << 8) |
- (input[ip++] << 16) | (input[ip++] << 24);
-
- // relative offset of local header
- this.relativeOffset =
- (input[ip++] ) | (input[ip++] << 8) |
- (input[ip++] << 16) | (input[ip++] << 24);
-
- // file name
- this.filename = String.fromCharCode.apply(null, USE_TYPEDARRAY ?
- input.subarray(ip, ip += this.fileNameLength) :
- input.slice(ip, ip += this.fileNameLength)
- );
-
- // extra field
- this.extraField = USE_TYPEDARRAY ?
- input.subarray(ip, ip += this.extraFieldLength) :
- input.slice(ip, ip += this.extraFieldLength);
-
- // file comment
- this.comment = USE_TYPEDARRAY ?
- input.subarray(ip, ip + this.fileCommentLength) :
- input.slice(ip, ip + this.fileCommentLength);
-
- this.length = ip - this.offset;
-};
-
-/**
- * @param {!(Array.<number>|Uint8Array)} input input buffer.
- * @param {number} ip input position.
- * @constructor
- */
-Zlib.Unzip.LocalFileHeader = function(input, ip) {
- /** @type {!(Array.<number>|Uint8Array)} */
- this.input = input;
- /** @type {number} */
- this.offset = ip;
- /** @type {number} */
- this.length;
- /** @type {number} */
- this.needVersion;
- /** @type {number} */
- this.flags;
- /** @type {number} */
- this.compression;
- /** @type {number} */
- this.time;
- /** @type {number} */
- this.date;
- /** @type {number} */
- this.crc32;
- /** @type {number} */
- this.compressedSize;
- /** @type {number} */
- this.plainSize;
- /** @type {number} */
- this.fileNameLength;
- /** @type {number} */
- this.extraFieldLength;
- /** @type {string} */
- this.filename;
- /** @type {!(Array.<number>|Uint8Array)} */
- this.extraField;
-};
-
-Zlib.Unzip.LocalFileHeader.Flags = Zlib.Zip.Flags;
-
-Zlib.Unzip.LocalFileHeader.prototype.parse = function() {
- /** @type {!(Array.<number>|Uint8Array)} */
- var input = this.input;
- /** @type {number} */
- var ip = this.offset;
-
- // local file header signature
- if (input[ip++] !== 0x50 || input[ip++] !== 0x4b ||
- input[ip++] !== 0x03 || input[ip++] !== 0x04) {
- throw new Error('invalid local file header signature');
- }
-
- // version needed to extract
- this.needVersion = input[ip++] | (input[ip++] << 8);
-
- // general purpose bit flag
- this.flags = input[ip++] | (input[ip++] << 8);
-
- // compression method
- this.compression = input[ip++] | (input[ip++] << 8);
-
- // last mod file time
- this.time = input[ip++] | (input[ip++] << 8);
-
- //last mod file date
- this.date = input[ip++] | (input[ip++] << 8);
-
- // crc-32
- this.crc32 = (
- (input[ip++] ) | (input[ip++] << 8) |
- (input[ip++] << 16) | (input[ip++] << 24)
- ) >>> 0;
-
- // compressed size
- this.compressedSize =
- (input[ip++] ) | (input[ip++] << 8) |
- (input[ip++] << 16) | (input[ip++] << 24);
-
- // uncompressed size
- this.plainSize =
- (input[ip++] ) | (input[ip++] << 8) |
- (input[ip++] << 16) | (input[ip++] << 24);
-
- // file name length
- this.fileNameLength = input[ip++] | (input[ip++] << 8);
-
- // extra field length
- this.extraFieldLength = input[ip++] | (input[ip++] << 8);
-
- // file name
- this.filename = String.fromCharCode.apply(null, USE_TYPEDARRAY ?
- input.subarray(ip, ip += this.fileNameLength) :
- input.slice(ip, ip += this.fileNameLength)
- );
-
- // extra field
- this.extraField = USE_TYPEDARRAY ?
- input.subarray(ip, ip += this.extraFieldLength) :
- input.slice(ip, ip += this.extraFieldLength);
-
- this.length = ip - this.offset;
-};
-
-
-Zlib.Unzip.prototype.searchEndOfCentralDirectoryRecord = function() {
- /** @type {!(Array.<number>|Uint8Array)} */
- var input = this.input;
- /** @type {number} */
- var ip;
-
- for (ip = input.length - 12; ip > 0; --ip) {
- if (input[ip ] === 0x50 && input[ip+1] === 0x4b &&
- input[ip+2] === 0x05 && input[ip+3] === 0x06) {
- this.eocdrOffset = ip;
- return;
- }
- }
-
- throw new Error('End of Central Directory Record not found');
-};
-
-Zlib.Unzip.prototype.parseEndOfCentralDirectoryRecord = function() {
- /** @type {!(Array.<number>|Uint8Array)} */
- var input = this.input;
- /** @type {number} */
- var ip;
-
- if (!this.eocdrOffset) {
- this.searchEndOfCentralDirectoryRecord();
- }
- ip = this.eocdrOffset;
-
- // signature
- if (input[ip++] !== 0x50 || input[ip++] !== 0x4b ||
- input[ip++] !== 0x05 || input[ip++] !== 0x06) {
- throw new Error('invalid signature');
- }
-
- // number of this disk
- this.numberOfThisDisk = input[ip++] | (input[ip++] << 8);
-
- // number of the disk with the start of the central directory
- this.startDisk = input[ip++] | (input[ip++] << 8);
-
- // total number of entries in the central directory on this disk
- this.totalEntriesThisDisk = input[ip++] | (input[ip++] << 8);
-
- // total number of entries in the central directory
- this.totalEntries = input[ip++] | (input[ip++] << 8);
-
- // size of the central directory
- this.centralDirectorySize =
- (input[ip++] ) | (input[ip++] << 8) |
- (input[ip++] << 16) | (input[ip++] << 24);
-
- // offset of start of central directory with respect to the starting disk number
- this.centralDirectoryOffset =
- (input[ip++] ) | (input[ip++] << 8) |
- (input[ip++] << 16) | (input[ip++] << 24);
-
- // .ZIP file comment length
- this.commentLength = input[ip++] | (input[ip++] << 8);
-
- // .ZIP file comment
- this.comment = USE_TYPEDARRAY ?
- input.subarray(ip, ip + this.commentLength) :
- input.slice(ip, ip + this.commentLength);
-};
-
-Zlib.Unzip.prototype.parseFileHeader = function() {
- /** @type {Array.<Zlib.Unzip.FileHeader>} */
- var filelist = [];
- /** @type {Object.<string, number>} */
- var filetable = {};
- /** @type {number} */
- var ip;
- /** @type {Zlib.Unzip.FileHeader} */
- var fileHeader;
- /*: @type {number} */
- var i;
- /*: @type {number} */
- var il;
-
- if (this.fileHeaderList) {
- return;
- }
-
- if (this.centralDirectoryOffset === void 0) {
- this.parseEndOfCentralDirectoryRecord();
- }
- ip = this.centralDirectoryOffset;
-
- for (i = 0, il = this.totalEntries; i < il; ++i) {
- fileHeader = new Zlib.Unzip.FileHeader(this.input, ip);
- fileHeader.parse();
- ip += fileHeader.length;
- filelist[i] = fileHeader;
- filetable[fileHeader.filename] = i;
- }
-
- if (this.centralDirectorySize < ip - this.centralDirectoryOffset) {
- throw new Error('invalid file header size');
- }
-
- this.fileHeaderList = filelist;
- this.filenameToIndex = filetable;
-};
-
-/**
- * @param {number} index file header index.
- * @return {!(Array.<number>|Uint8Array)} file data.
- */
-Zlib.Unzip.prototype.getFileData = function(index) {
- /** @type {!(Array.<number>|Uint8Array)} */
- var input = this.input;
- /** @type {Array.<Zlib.Unzip.FileHeader>} */
- var fileHeaderList = this.fileHeaderList;
- /** @type {Zlib.Unzip.LocalFileHeader} */
- var localFileHeader;
- /** @type {number} */
- var offset;
- /** @type {number} */
- var length;
- /** @type {!(Array.<number>|Uint8Array)} */
- var buffer;
- /** @type {number} */
- var crc32;
- /** @type {Array.<number>|Uint32Array} */
- var key;
- /** @type {number} */
- var i;
- /** @type {number} */
- var il;
-
- if (!fileHeaderList) {
- this.parseFileHeader();
- }
-
- if (fileHeaderList[index] === void 0) {
- throw new Error('wrong index');
- }
-
- offset = fileHeaderList[index].relativeOffset;
- localFileHeader = new Zlib.Unzip.LocalFileHeader(this.input, offset);
- localFileHeader.parse();
- offset += localFileHeader.length;
- length = localFileHeader.compressedSize;
-
- // decryption
- if ((localFileHeader.flags & Zlib.Unzip.LocalFileHeader.Flags.ENCRYPT) !== 0) {
- if (!this.password) {
- throw new Error('please set password');
- }
- key = this.createDecryptionKey(this.password);
-
- // encryption header
- for(i = offset, il = offset + 12; i < il; ++i) {
- this.decode(key, input[i]);
- }
- offset += 12;
- length -= 12;
-
- // decryption
- for (i = offset, il = offset + length; i < il; ++i) {
- input[i] = this.decode(key, input[i]);
- }
- }
-
- switch (localFileHeader.compression) {
- case Zlib.Unzip.CompressionMethod.STORE:
- buffer = USE_TYPEDARRAY ?
- this.input.subarray(offset, offset + length) :
- this.input.slice(offset, offset + length);
- break;
- case Zlib.Unzip.CompressionMethod.DEFLATE:
- buffer = new Zlib.RawInflate(this.input, {
- 'index': offset,
- 'bufferSize': localFileHeader.plainSize
- }).decompress();
- break;
- default:
- throw new Error('unknown compression type');
- }
-
- if (this.verify) {
- crc32 = Zlib.CRC32.calc(buffer);
- if (localFileHeader.crc32 !== crc32) {
- throw new Error(
- 'wrong crc: file=0x' + localFileHeader.crc32.toString(16) +
- ', data=0x' + crc32.toString(16)
- );
- }
- }
-
- return buffer;
-};
-
-/**
- * @return {Array.<string>}
- */
-Zlib.Unzip.prototype.getFilenames = function() {
- /** @type {Array.<string>} */
- var filenameList = [];
- /** @type {number} */
- var i;
- /** @type {number} */
- var il;
- /** @type {Array.<Zlib.Unzip.FileHeader>} */
- var fileHeaderList;
-
- if (!this.fileHeaderList) {
- this.parseFileHeader();
- }
- fileHeaderList = this.fileHeaderList;
-
- for (i = 0, il = fileHeaderList.length; i < il; ++i) {
- filenameList[i] = fileHeaderList[i].filename;
- }
-
- return filenameList;
-};
-
-/**
- * @param {string} filename extract filename.
- * @return {!(Array.<number>|Uint8Array)} decompressed data.
- */
-Zlib.Unzip.prototype.decompress = function(filename) {
- /** @type {number} */
- var index;
-
- if (!this.filenameToIndex) {
- this.parseFileHeader();
- }
- index = this.filenameToIndex[filename];
-
- if (index === void 0) {
- throw new Error(filename + ' not found');
- }
-
- return this.getFileData(index);
-};
-
-/**
- * @param {(Array.<number>|Uint8Array)} password
- */
-Zlib.Unzip.prototype.setPassword = function(password) {
- this.password = password;
-};
-
-/**
- * @param {(Array.<number>|Uint32Array)} key
- * @param {number} n
- * @returns {number}
- */
-Zlib.Unzip.prototype.decode = function(key, n) {
- n ^= this.getByte(key);
- this.updateKeys(key, n);
-
- return n;
-};
-
-// common method
-Zlib.Unzip.prototype.updateKeys = Zlib.Zip.prototype.updateKeys;
-Zlib.Unzip.prototype.createDecryptionKey = Zlib.Zip.prototype.createEncryptionKey;
-Zlib.Unzip.prototype.getByte = Zlib.Zip.prototype.getByte;
-
-// end of scope
-});
+++ /dev/null
-/**
- * @fileoverview 雑多な関数群をまとめたモジュール実装.
- */
-goog.provide('Zlib.Util');
-
-goog.scope(function() {
-
-/**
- * Byte String から Byte Array に変換.
- * @param {!string} str byte string.
- * @return {!Array.<number>} byte array.
- */
-Zlib.Util.stringToByteArray = function(str) {
- /** @type {!Array.<(string|number)>} */
- var tmp = str.split('');
- /** @type {number} */
- var i;
- /** @type {number} */
- var il;
-
- for (i = 0, il = tmp.length; i < il; i++) {
- tmp[i] = (tmp[i].charCodeAt(0) & 0xff) >>> 0;
- }
-
- return tmp;
-};
-
-// end of scope
-});
-
-/* vim:set expandtab ts=2 sw=2 tw=80: */
+++ /dev/null
-goog.provide('Zlib.Zip');
-
-goog.require('USE_TYPEDARRAY');
-goog.require('Zlib.RawDeflate');
-goog.require('Zlib.CRC32');
-
-goog.scope(function() {
-
-/**
- * @param {Object=} opt_params options.
- * @constructor
- */
-Zlib.Zip = function(opt_params) {
- opt_params = opt_params || {};
- /** @type {Array.<{
- * buffer: !(Array.<number>|Uint8Array),
- * option: Object,
- * compressed: boolean,
- * encrypted: boolean,
- * size: number,
- * crc32: number
- * }>} */
- this.files = [];
- /** @type {(Array.<number>|Uint8Array)} */
- this.comment = opt_params['comment'];
- /** @type {(Array.<number>|Uint8Array)} */
- this.password;
-};
-
-
-/**
- * @enum {number}
- */
-Zlib.Zip.CompressionMethod = {
- STORE: 0,
- DEFLATE: 8
-};
-
-/**
- * @enum {number}
- */
-Zlib.Zip.OperatingSystem = {
- MSDOS: 0,
- UNIX: 3,
- MACINTOSH: 7
-};
-
-/**
- * @enum {number}
- */
-Zlib.Zip.Flags = {
- ENCRYPT: 0x0001,
- DESCRIPTER: 0x0008,
- UTF8: 0x0800
-};
-
-/**
- * @param {Array.<number>|Uint8Array} input
- * @param {Object=} opt_params options.
- */
-Zlib.Zip.prototype.addFile = function(input, opt_params) {
- opt_params = opt_params || {};
- /** @type {string} */
- var filename = '' || opt_params['filename'];
- /** @type {boolean} */
- var compressed;
- /** @type {number} */
- var size = input.length;
- /** @type {number} */
- var crc32 = 0;
-
- if (USE_TYPEDARRAY && input instanceof Array) {
- input = new Uint8Array(input);
- }
-
- // default
- if (typeof opt_params['compressionMethod'] !== 'number') {
- opt_params['compressionMethod'] = Zlib.Zip.CompressionMethod.DEFLATE;
- }
-
- // その場で圧縮する場合
- if (opt_params['compress']) {
- switch (opt_params['compressionMethod']) {
- case Zlib.Zip.CompressionMethod.STORE:
- break;
- case Zlib.Zip.CompressionMethod.DEFLATE:
- crc32 = Zlib.CRC32.calc(input);
- input = this.deflateWithOption(input, opt_params);
- compressed = true;
- break;
- default:
- throw new Error('unknown compression method:' + opt_params['compressionMethod']);
- }
- }
-
- this.files.push({
- buffer: input,
- option: opt_params,
- compressed: compressed,
- encrypted: false,
- size: size,
- crc32: crc32
- });
-};
-
-/**
- * @param {(Array.<number>|Uint8Array)} password
- */
-Zlib.Zip.prototype.setPassword = function(password) {
- this.password = password;
-};
-
-Zlib.Zip.prototype.compress = function() {
- /** @type {Array.<{
- * buffer: !(Array.<number>|Uint8Array),
- * option: Object,
- * compressed: boolean,
- * encrypted: boolean,
- * size: number,
- * crc32: number
- * }>} */
- var files = this.files;
- /** @type {{
- * buffer: !(Array.<number>|Uint8Array),
- * option: Object,
- * compressed: boolean,
- * encrypted: boolean,
- * size: number,
- * crc32: number
- * }} */
- var file;
- /** @type {!(Array.<number>|Uint8Array)} */
- var output;
- /** @type {number} */
- var op1;
- /** @type {number} */
- var op2;
- /** @type {number} */
- var op3;
- /** @type {number} */
- var localFileSize = 0;
- /** @type {number} */
- var centralDirectorySize = 0;
- /** @type {number} */
- var endOfCentralDirectorySize;
- /** @type {number} */
- var offset;
- /** @type {number} */
- var needVersion;
- /** @type {number} */
- var flags;
- /** @type {Zlib.Zip.CompressionMethod} */
- var compressionMethod;
- /** @type {Date} */
- var date;
- /** @type {number} */
- var crc32;
- /** @type {number} */
- var size;
- /** @type {number} */
- var plainSize;
- /** @type {number} */
- var filenameLength;
- /** @type {number} */
- var extraFieldLength;
- /** @type {number} */
- var commentLength;
- /** @type {(Array.<number>|Uint8Array)} */
- var filename;
- /** @type {(Array.<number>|Uint8Array)} */
- var extraField;
- /** @type {(Array.<number>|Uint8Array)} */
- var comment;
- /** @type {(Array.<number>|Uint8Array)} */
- var buffer;
- /** @type {*} */
- var tmp;
- /** @type {Array.<number>|Uint32Array} */
- var key;
- /** @type {number} */
- var i;
- /** @type {number} */
- var il;
- /** @type {number} */
- var j;
- /** @type {number} */
- var jl;
-
- // ファイルの圧縮
- for (i = 0, il = files.length; i < il; ++i) {
- file = files[i];
- filenameLength =
- (file.option['filename']) ? file.option['filename'].length : 0;
- extraFieldLength =
- (file.option['extraField']) ? file.option['extraField'].length : 0;
- commentLength =
- (file.option['comment']) ? file.option['comment'].length : 0;
-
- // 圧縮されていなかったら圧縮
- if (!file.compressed) {
- // 圧縮前に CRC32 の計算をしておく
- file.crc32 = Zlib.CRC32.calc(file.buffer);
-
- switch (file.option['compressionMethod']) {
- case Zlib.Zip.CompressionMethod.STORE:
- break;
- case Zlib.Zip.CompressionMethod.DEFLATE:
- file.buffer = this.deflateWithOption(file.buffer, file.option);
- file.compressed = true;
- break;
- default:
- throw new Error('unknown compression method:' + file.option['compressionMethod']);
- }
- }
-
- // encryption
- if (this.password !== void 0) {
- // init encryption
- key = this.createEncryptionKey(this.password);
-
- // add header
- buffer = file.buffer;
- if (USE_TYPEDARRAY) {
- tmp = new Uint8Array(buffer.length + 12);
- tmp.set(buffer, 12);
- buffer = tmp;
- } else {
- buffer.unshift(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
- }
-
- for (j = 0; j < 12; ++j) {
- buffer[j] = this.encode(
- key,
- i === 11 ? (file.crc32 & 0xff) : (Math.random() * 256 | 0)
- );
- }
-
- // data encryption
- for (jl = buffer.length; j < jl; ++j) {
- buffer[j] = this.encode(key, buffer[j]);
- }
- file.buffer = buffer;
- }
-
- // 必要バッファサイズの計算
- localFileSize +=
- // local file header
- 30 + filenameLength +
- // file data
- file.buffer.length;
-
- centralDirectorySize +=
- // file header
- 46 + filenameLength + commentLength;
- }
-
- // end of central directory
- endOfCentralDirectorySize = 46 + (this.comment ? this.comment.length : 0);
- output = new (USE_TYPEDARRAY ? Uint8Array : Array)(
- localFileSize + centralDirectorySize + endOfCentralDirectorySize
- );
- op1 = 0;
- op2 = localFileSize;
- op3 = op2 + centralDirectorySize;
-
- // ファイルの圧縮
- for (i = 0, il = files.length; i < il; ++i) {
- file = files[i];
- filenameLength =
- file.option['filename'] ? file.option['filename'].length : 0;
- extraFieldLength = 0; // TODO
- commentLength =
- file.option['comment'] ? file.option['comment'].length : 0;
-
- //-------------------------------------------------------------------------
- // local file header & file header
- //-------------------------------------------------------------------------
-
- offset = op1;
-
- // signature
- output[op1++] = output[op2++] = 0x50;
- output[op1++] = output[op2++] = 0x4b;
- output[op1++] = 0x03; // local file header
- output[op1++] = 0x04;
- output[op2++] = 0x01; // file header
- output[op2++] = 0x02;
-
- // compressor info
- needVersion = 20;
- output[op2++] = needVersion & 0xff;
- output[op2++] =
- /** @type {Zlib.Zip.OperatingSystem} */
- (file.option['os']) ||
- Zlib.Zip.OperatingSystem.MSDOS;
-
- // need version
- output[op1++] = output[op2++] = needVersion & 0xff;
- output[op1++] = output[op2++] = (needVersion >> 8) & 0xff;
-
- // general purpose bit flag
- flags = 0;
- if (this.password) {
- flags |= Zlib.Zip.Flags.ENCRYPT;
- }
- output[op1++] = output[op2++] = flags & 0xff;
- output[op1++] = output[op2++] = (flags >> 8) & 0xff;
-
- // compression method
- compressionMethod =
- /** @type {Zlib.Zip.CompressionMethod} */
- (file.option['compressionMethod']);
- output[op1++] = output[op2++] = compressionMethod & 0xff;
- output[op1++] = output[op2++] = (compressionMethod >> 8) & 0xff;
-
- // date
- date = /** @type {(Date|undefined)} */(file.option['date']) || new Date();
- output[op1++] = output[op2++] =
- ((date.getMinutes() & 0x7) << 5) |
- (date.getSeconds() / 2 | 0);
- output[op1++] = output[op2++] =
- (date.getHours() << 3) |
- (date.getMinutes() >> 3);
- //
- output[op1++] = output[op2++] =
- ((date.getMonth() + 1 & 0x7) << 5) |
- (date.getDate());
- output[op1++] = output[op2++] =
- ((date.getFullYear() - 1980 & 0x7f) << 1) |
- (date.getMonth() + 1 >> 3);
-
- // CRC-32
- crc32 = file.crc32;
- output[op1++] = output[op2++] = crc32 & 0xff;
- output[op1++] = output[op2++] = (crc32 >> 8) & 0xff;
- output[op1++] = output[op2++] = (crc32 >> 16) & 0xff;
- output[op1++] = output[op2++] = (crc32 >> 24) & 0xff;
-
- // compressed size
- size = file.buffer.length;
- output[op1++] = output[op2++] = size & 0xff;
- output[op1++] = output[op2++] = (size >> 8) & 0xff;
- output[op1++] = output[op2++] = (size >> 16) & 0xff;
- output[op1++] = output[op2++] = (size >> 24) & 0xff;
-
- // uncompressed size
- plainSize = file.size;
- output[op1++] = output[op2++] = plainSize & 0xff;
- output[op1++] = output[op2++] = (plainSize >> 8) & 0xff;
- output[op1++] = output[op2++] = (plainSize >> 16) & 0xff;
- output[op1++] = output[op2++] = (plainSize >> 24) & 0xff;
-
- // filename length
- output[op1++] = output[op2++] = filenameLength & 0xff;
- output[op1++] = output[op2++] = (filenameLength >> 8) & 0xff;
-
- // extra field length
- output[op1++] = output[op2++] = extraFieldLength & 0xff;
- output[op1++] = output[op2++] = (extraFieldLength >> 8) & 0xff;
-
- // file comment length
- output[op2++] = commentLength & 0xff;
- output[op2++] = (commentLength >> 8) & 0xff;
-
- // disk number start
- output[op2++] = 0;
- output[op2++] = 0;
-
- // internal file attributes
- output[op2++] = 0;
- output[op2++] = 0;
-
- // external file attributes
- output[op2++] = 0;
- output[op2++] = 0;
- output[op2++] = 0;
- output[op2++] = 0;
-
- // relative offset of local header
- output[op2++] = offset & 0xff;
- output[op2++] = (offset >> 8) & 0xff;
- output[op2++] = (offset >> 16) & 0xff;
- output[op2++] = (offset >> 24) & 0xff;
-
- // filename
- filename = file.option['filename'];
- if (filename) {
- if (USE_TYPEDARRAY) {
- output.set(filename, op1);
- output.set(filename, op2);
- op1 += filenameLength;
- op2 += filenameLength;
- } else {
- for (j = 0; j < filenameLength; ++j) {
- output[op1++] = output[op2++] = filename[j];
- }
- }
- }
-
- // extra field
- extraField = file.option['extraField'];
- if (extraField) {
- if (USE_TYPEDARRAY) {
- output.set(extraField, op1);
- output.set(extraField, op2);
- op1 += extraFieldLength;
- op2 += extraFieldLength;
- } else {
- for (j = 0; j < commentLength; ++j) {
- output[op1++] = output[op2++] = extraField[j];
- }
- }
- }
-
- // comment
- comment = file.option['comment'];
- if (comment) {
- if (USE_TYPEDARRAY) {
- output.set(comment, op2);
- op2 += commentLength;
- } else {
- for (j = 0; j < commentLength; ++j) {
- output[op2++] = comment[j];
- }
- }
- }
-
- //-------------------------------------------------------------------------
- // file data
- //-------------------------------------------------------------------------
-
- if (USE_TYPEDARRAY) {
- output.set(file.buffer, op1);
- op1 += file.buffer.length;
- } else {
- for (j = 0, jl = file.buffer.length; j < jl; ++j) {
- output[op1++] = file.buffer[j];
- }
- }
- }
-
- //-------------------------------------------------------------------------
- // end of central directory
- //-------------------------------------------------------------------------
-
- // signature
- output[op3++] = 0x50;
- output[op3++] = 0x4b;
- output[op3++] = 0x05;
- output[op3++] = 0x06;
-
- // number of this disk
- output[op3++] = 0;
- output[op3++] = 0;
-
- // number of the disk with the start of the central directory
- output[op3++] = 0;
- output[op3++] = 0;
-
- // total number of entries in the central directory on this disk
- output[op3++] = il & 0xff;
- output[op3++] = (il >> 8) & 0xff;
-
- // total number of entries in the central directory
- output[op3++] = il & 0xff;
- output[op3++] = (il >> 8) & 0xff;
-
- // size of the central directory
- output[op3++] = centralDirectorySize & 0xff;
- output[op3++] = (centralDirectorySize >> 8) & 0xff;
- output[op3++] = (centralDirectorySize >> 16) & 0xff;
- output[op3++] = (centralDirectorySize >> 24) & 0xff;
-
- // offset of start of central directory with respect to the starting disk number
- output[op3++] = localFileSize & 0xff;
- output[op3++] = (localFileSize >> 8) & 0xff;
- output[op3++] = (localFileSize >> 16) & 0xff;
- output[op3++] = (localFileSize >> 24) & 0xff;
-
- // .ZIP file comment length
- commentLength = this.comment ? this.comment.length : 0;
- output[op3++] = commentLength & 0xff;
- output[op3++] = (commentLength >> 8) & 0xff;
-
- // .ZIP file comment
- if (this.comment) {
- if (USE_TYPEDARRAY) {
- output.set(this.comment, op3);
- op3 += commentLength;
- } else {
- for (j = 0, jl = commentLength; j < jl; ++j) {
- output[op3++] = this.comment[j];
- }
- }
- }
-
- return output;
-};
-
-/**
- * @param {!(Array.<number>|Uint8Array)} input
- * @param {Object=} opt_params options.
- * @return {!(Array.<number>|Uint8Array)}
- */
-Zlib.Zip.prototype.deflateWithOption = function(input, opt_params) {
- /** @type {Zlib.RawDeflate} */
- var deflator = new Zlib.RawDeflate(input, opt_params['deflateOption']);
-
- return deflator.compress();
-};
-
-/**
- * @param {(Array.<number>|Uint32Array)} key
- * @returns {number}
- */
-Zlib.Zip.prototype.getByte = function(key) {
- /** @type {number} */
- var tmp = ((key[2] & 0xffff) | 2);
-
- return ((tmp * (tmp ^ 1)) >> 8) & 0xff;
-};
-
-/**
- * @param {(Array.<number>|Uint32Array)} key
- * @param {number} n
- * @returns {number}
- */
-Zlib.Zip.prototype.encode = function(key, n) {
- /** @type {number} */
- var tmp = this.getByte(key);
-
- this.updateKeys(key, n);
-
- return tmp ^ n;
-};
-
-/**
- * @param {(Array.<number>|Uint32Array)} key
- * @param {number} n
- */
-Zlib.Zip.prototype.updateKeys = function(key, n) {
- key[0] = Zlib.CRC32.single(key[0], n);
- key[1] =
- (((((key[1] + (key[0] & 0xff)) * 20173 >>> 0) * 6681) >>> 0) + 1) >>> 0;
- key[2] = Zlib.CRC32.single(key[2], key[1] >>> 24);
-};
-
-/**
- * @param {(Array.<number>|Uint8Array)}password
- * @returns {Array.<number>|Uint32Array}
- */
-Zlib.Zip.prototype.createEncryptionKey = function(password) {
- /** @type {(Array.<number>|Uint32Array)} */
- var key = [305419896, 591751049, 878082192];
- /** @type {number} */
- var i;
- /** @type {number} */
- var il;
-
- if (USE_TYPEDARRAY) {
- key = new Uint32Array(key);
- }
-
- for (i = 0, il = password.length; i < il; ++i) {
- this.updateKeys(key, password[i] & 0xff);
- }
-
- return key;
-};
-
-});
\ No newline at end of file
+++ /dev/null
-/**
- * @fileoverview Zlib namespace. Zlib の仕様に準拠した圧縮は Zlib.Deflate で実装
- * されている. これは Inflate との共存を考慮している為.
- */
-
-goog.provide('Zlib');
-
-//-----------------------------------------------------------------------------
-
-goog.scope(function() {
-
-/**
- * Compression Method
- * @enum {number}
- */
-Zlib.CompressionMethod = {
- DEFLATE: 8,
- RESERVED: 15
-};
-
-// end of scope
-});
-
-/* vim:set expandtab ts=2 sw=2 tw=80: */
+++ /dev/null
-# Generated file, but its source is also present
-source-is-missing debian/missing-sources/zlib.js-0.1.6/deps.js *